Monte Carlo Tree Search Algorithm used to solve 2048 puzzles.
This Artificial Intelligence algorithm (Monte Carlo Tree Search) attempts to maximize the amount of score gained while also attempting to minimize the number of moves used.
It can be visualised as a tree that displays the current situation as the root node and then roots down across many paths and chooses a valid path that maximizes score (reaching a leaf node) in the shortest amount of moves.
-
Make sure to have Python 3.9 installed on your local system.
-
Install the required python packages for the project to work (pygame and numpy).
$ pip install requirements.txt
-
Run the game.py script by executing this command in a terminal
$ python3 game.py
To my surprise, this algorithm doesn't just beat 2048, it actually demolishes it in every way possible. Just in my 4th attempt, I was able to reach upto ~170k scores. This algorithm has beaten most other 2048 artificial intelligence algorithms that I have seen out there and its potential scares me.