AI-based 2048 logo

Programming an AI-based 2048 game (Part 1: Presentation)

Origin of this project

Few years ago, I followed and completed a Massive Open Online Course (MOOC) on the Coursera platform about Machine Learning. This MOOC has been created (and it is regularly updated since) by Andrew Ng, a Professor at Standford University who also happens to be the co-funder of Coursera and the founding lead of Google Brain…

To me, this MOOC was the very first introduction to what more and more people are now calling “Artificial Intelligence” (AI). Whether we use Machine Learning or Artificial Intelligence terminology, we see more and more use cases where systems have to perform a narrow task based on some algorithms and (history) data.

For instance, a lot of AI-based systems are now trusted to:

  • Recommend better content to its users (Netflix, Facebook, etc.);
  • Drive/park in public environments such as cities (autonomous cars);
  • Classify and sort mail/packages even if addresses are handwritten (postal service);
  • Etc…

Of course, predictions of all these systems strongly depend on the algorithms used as well as “data quality”.

As far as I was concerned, I was pretty impressed by how quickly the Coursera Machine Learning MOOC guided me through the steps to code a neural network able to recognize an handwritten digit number. In fact, the only material I needed was… data! For that particular example, and as suggested by Andrew Ng, I used the MNIST database of handwritten digits (see image below).

Examples from a dataset used to train a neural network.
Even for a human, all digits cannot be recognized easily…
© Andrew Ng – Coursera MOOC

What is my goal with this personal project?

Through a series of blog posts, I want to illustrate how some AI concepts can be applied to a simple video game that everyone knows: 2048.

My main motivation behind this project is to re-use the concepts I learned from Andrew Ng’s MOOC. Without looking at solutions that may already be available online, I want to develop a program from scratch able to play (and if possible to win) to the 2048 video game.

My two initial constraints are:

  1. I intend to develop a basic graphical interface to play 2048 games. It will also be especially helpful to see the different moves that have been played over time (replay mode according to history);
  2. Among all available “AI algorithms”, I will first focus on neural networks so my program will be able to learn from some 2048 games previously played by a human player (in other words, me).

I will develop this project in Python 3. The source code of this game will be freely available on my Github. I will try to document my code as much as possible and do several commits so you can see the project evolution and/or practice on your own.

Of course, I do not guarantee that my solution will be the best or the most optimized one so feel free to propose yours or any suggestion you may have by commenting this series of blog posts.

I hope you enjoyed reading this first blog post regarding my project to design and develop an AI-based 2048 game and that you are impatient for the next blog posts. 🙂