Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
duducheng committed Sep 28, 2018
1 parent 6fba5d5 commit 3f56fc0
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,49 @@
# 2048-api
A 2048 game api for training supervised learning (imitation learning) or reinforcement learning agents

# To compile the pre-defined [ExpectiMax](https://github.com/nneonneo/2048-ai) agent
# Code structure
* [`game2048/`](game2048/): the main package.
* [`game.py`](game2048/game.py): the core 2048 `Game` class.
* [`agents.py`](game2048/agents.py): the `Agent` class with instances.
* [`displays`](game2048/displays.py): the `Display` class with instances, to show the `Game` state.
* [`expectimax/`](game2048/expectimax): a powerful ExpectiMax agent by [here](https://github.com/nneonneo/2048-ai).
* [`explore.ipynb`](explore.ipynb): introduce how to use the `Agent`, `Display` and `Game`.
* [`static/`](static/): html assets for web app.
* [`webapp.py`](webapp.py): run the web app demo.
* [`evaluate.py`](evaluate.py): evaluate your self-defined agent.

# To define your own agents
```python
from game2048.agents import Agent

class YourOwnAgent(Agent):

def step(self):
'''To define the agent's 1-step behavior given the `game`.
You can find more instance in [`agents.py`](game2048/agents.py).
:return direction: 0: left, 1: down, 2: right, 3: up
'''
direction = some_function(self.game)
return direction

```

# To compile the pre-defined ExpectiMax agent

```bash
cd game2048/expectimax
bash configure
make
```

# To run the webapp
# To run the web app
```bash
python webapp.py
```
![demo](preview2048.gif)

# LICENSE
The code is under Apache-2.0 License.


0 comments on commit 3f56fc0

Please sign in to comment.