Programming an AI-based 2048 game (Part 4: Neural Network and Wrapping Up)

This fourth blog post concludes my personal project of developing an AI-based 2048 video game in Python 3. Feel free to check the first blog post of this series out if you haven’t read it yet.

If you want more details, the source code of the project is also available on Github.

This fourth and last post will focus on implementing the Neural Network itself and show a basic train/play cycle. Initially, I also wanted to demonstrate how this AI-based 2048 was (almost) always performing better than a Human but, well, you will see that it did not go as good as planned… 😀

Read more

Programming an AI-based 2048 game (Part 3: User Interface)

This third blog post presents the User Interface that I designed for my 2048 video game (you can check the first blog post of this series out if you haven’t read it yet).

I chose to rely on the very good tkinter package, which is the standard Python interface to the Tk GUI toolkit. Both Tk and tkinter are available on most Unix platforms, as well as on Windows systems. More details are available on the official documentation website.

This third post will mainly describe the TkConstants and Window classes. If you want more details, the source code of the project is also available on Github.

Read more

Programming an AI-based 2048 game (Part 2: Game logic)

As I was previously writing about, I am currently in the middle of developing a custom AI-based Python program able to play to the 2048 video game (you can check the first blog post of this series out if you haven’t read it yet).

So let’s state the obvious: if you want an algorithm to play to a video game, you first have to implement it, right? Basically, this means to “translate” the different rules of your video game, such as: What does it mean to win? What about loosing? What are the allowed moves? etc.

This second blog post presents the three most important classes (namely Game, Grid and History) I defined to model the 2048 game logic. For those who are impatient to see some User Interfaces (UIs) and Neural Networks, please just hang in there because -spoiler alert- these topics are coming up in the next posts (actually UI presentation is coming up right away in the next blog post. 😉

Read more

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.