Our project is an extension of another repo (https://github.com/voldikss/EE369-2048-AI)
Below is a list of methods/classes that we either created or modified/added to:
task/agents.pyMarkovModelclassLearningAgentclassGreedyAgentclassload_states_probsmethoddetermine_rewardsmethodis_winmethodis_lossmethodis_mergeablemethodstepmethodcalc_rewardmethod
game2048/agents.pyplay_learnmethodconvert_statemethod
learn_probabilities.pylearned_states_probs.txt
For SJTU EE369 final project.
Use supervised learning (imitation learning) and tree searching approaches to solve the game of 2048.
game2048/: the main package.game.py: the core 2048Gameclass.agents.py: theAgentclass with instances.displays.py: theDisplayclass with instances, to show theGamestate.expectimax/: a powerful ExpectiMax agent by here.
task/: the implementation of supervised learning and tree searching.agents.py: theAgentclasses of supervised learning and tree searching.model.py: the convolutional neural network model.offline_training.py: offline method for training.online_training.py: online method for training.planning.py: the tree searching approach solution of the game.util.py: tools to process the game board.model_0_1024.h5: the dumped CNN model.
explore.ipynb: introduce how to use theAgent,DisplayandGame.static/: frontend assets (based on Vue.js) for web app.webapp.py: run the web app (backend) demo.evaluate.py: evaluate the self-defined agent.
- To evaluate the supervised learning model, run
# Will play the game for 50 times and return the average score
python evaluate.py --agent=cnnagentP.S. Currently the max score is 1024, the average score is 541.44.
- To evaluate the tree searching method, run
python evaluate.py --agent=pagentP.S. With the depth set to 3, the planning method can reach the score 2048.
python webapp.py
You can also specify an agent by adding --agent. cnnagent, pagent, emagent are usable, RandomAgent by default.
For example, run the web app with the planning agent
python webapp.py --agent=pagencd game2048/expectimax
bash configure
makeThe code is under Apache-2.0 License. pp.
