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.py
MarkovModel
classLearningAgent
classGreedyAgent
classload_states_probs
methoddetermine_rewards
methodis_win
methodis_loss
methodis_mergeable
methodstep
methodcalc_reward
method
game2048/agents.py
play_learn
methodconvert_state
method
learn_probabilities.py
learned_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 2048Game
class.agents.py
: theAgent
class with instances.displays.py
: theDisplay
class with instances, to show theGame
state.expectimax/
: a powerful ExpectiMax agent by here.
task/
: the implementation of supervised learning and tree searching.agents.py
: theAgent
classes 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
,Display
andGame
.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=cnnagent
P.S. Currently the max score is 1024, the average score is 541.44.
- To evaluate the tree searching method, run
python evaluate.py --agent=pagent
P.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=pagen
cd game2048/expectimax
bash configure
make
The code is under Apache-2.0 License. pp.