Inspiration
One of our team mates is a big fan of the famous 2048 game, our team also found that making an AI bot for 2048 game is a both challenging and interesting project which also a good practice of programming and project managing.
What it does
After execution of the program, it will open the 2048.org website with default web browser and start playing it.
What it include
- A 2048 CLI game simulation along with the AI bot (using the three java file: gameManager.java, board.java, and simulate.java; or using single file manager.java with modify line 94 into "while(moveCount < 3000 && !theboard.isLost())" and setting false in line 82) video demonstration is the following: https://youtu.be/stTxM02_438
- A python controlled image processing module combined working with the Manager.jar, which solves for the online 2048 game. video demonstration is included in above
How we built it
The project is done in roughly 3 steps simultaneously:
- Programming and testing the AI bot for movement decision which uses information of current game number and distribution, it is done in Java. It is trained and tested with a CLI game simulate and takes CLI input.
- Programming using openCV package to detect, processing, and convert the web game’s current number and distribution from screenshot into number array. It is done in Python.
- Combining these source files with different programming languages by using pre-regulated API, make the whole project working
Challenges we ran into
The AI bot developing do take a lot work and it runs smoothly. The AI bot part is capable of having a moderate high rate of getting an 2048 as the game result. The image processing and conversion part is the challenging one in the project. We did this by first get the location of the 4x4 board, then split the 16 numbers in image and get the numbers. It reveals some detection confusion (for example in seperating 16 and 64)currently. It do affect the efficiency of the AI bot. Managing package and running environment on different platforms is also a challenging part in developing this project.
Update: We replaced the basic BF-match algorithm into BFmatch-knn, the image recognition is much better and works almost perfectly in reading numbers (no 16 and 64 confusion issue now). Still, User should giving a custom template image in their monitor resolution (replacing template2048.png) to have the best result for image recognition.
Accomplishments that we're proud of
The AI bot part is capable of having a moderate high rate of getting an 2048 as the game result. The usage and adjustment of openCV based image processing gives relatively high accuracy (however rare error still make big difference on winning the game). And, making the whole project running with multiple files in different programming languages.
What we learned
Project managing with different programming language and different platform; programming technique and algorithm which can be used beyond solving the 2048 game; a brief intro for us in computer vision and machine learning using openCV package.
What's next for 2048bot (404_DNE)
Making the imaging processing better with further adjustment of the current model, so that it could provide a very accurate result of ‘reading’ the numbers. Better packaging technique for publishing the project so that it could running alone, without installing multiple packages.
Log in or sign up for Devpost to join the conversation.