Modification of Gariele Cirulli's 2048 to include player and system AI. View it on Github Pages.
In order to speed up execution time, ai.js contains code compiled using Emscripten compiler. Follow the below steps to modify ai.js:
- Make sure you have Emscripten installed.
- Get TommyDS and place its C files in the
src
folder. The hashtable provided by TommyDS is used to cache parts of the expectimax search. - Make the desired changes in
src/ai.c
. - Compile to
js/ai.js
by running the following in the root folder:emcc src/tommy.c src/ai.c -o js/ai.js -O3 --post-js "src/ai.post.js" -s EXPORTED_FUNCTIONS="['_main', '_next_player_move', '_next_system_tile']" --memory-init-file 0
2048 is licensed under the MIT license.