The Puzzle Game of 2048 offers a deeply engaging and strategically complex challenge despite its minimalist design and simplistic rule set. Thanks to this addictive nature, it has reached over 23 million players since its release in 2014.
2048 has also experienced strong interest among researchers, both as a challenge to develop the best-performing algorithm and also as an excellent platform to benchmark Reinforcement Learning techniques.
The core objectives of this project were to examine the mathematical properties of 2048, to implement a highly optimised simulation framework, and to develop a well-performing algorithm by combining various Reinforcement Learning approaches with Computational Mathematics and experimentally perfected novel contributions.
- Clone the repository to your local machine with:
git clone https://github.com/Cence2002/2048_CPP.git
- Navigate to the root directory of the repository:
cd 2048_CPP
- Create new build directory and navigate to it:
mkdir build && cd build
- Run CMake to generate the build files:
cmake ..
- Build the project:
make
- Run the built executable to run the program:
./2048
- Alternatively, run the other executable to perform validity tests:
./tests
- To clean the build files, run:
make clean
The testing and training configurations are intuitively customisable at the top of main.cpp where these setting are abstracted into constexpr variables to avoid sacrificing performance.
Combining all value approximation enhancement strategies wit two novel additions - PNP and BFCS -- our method can achieve:
- Average score over 600,000, over 95% of the current state-of-the-art (reaching an average of 625,000)
- Using only 1-2 milliseconds per move, which is less, than 1-2% of the thinking time of the current state-of-the-art (using 0.4 seconds per move)
These results make our solution one of the most efficient algorithm for 2048, and arguably the most sophisticated decision-making strategy to date.
This project was completed as a prerequisite for Part II of Computer Science Tripos (2024) at the University of Cambridge.
The project is protected by the standard MIT License, which is included in the repository and can be found below: