faymek / 2048-api

A 2048 api for training supervised learning (imitation learning) or reinforcement learning agents

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

2048-api

A 2048 game api for training supervised learning (imitation learning) or reinforcement learning agents

Code structure

Requirements

  • code only tested on linux system (ubuntu 16.04)
  • Python 3 (Anaconda 3.6.3 specifically) with numpy and flask

To define your own agents

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

cd game2048/expectimax
bash configure
make

To run the web app

python webapp.py

demo

Code structure

  • best/ current best model saving directory.
  • dev/ models under developing , or base model in two hierarchy method.
  • game2048/ game's api.
  • models/ several models archived in different scores.
  • multi/ temporary directory for offline data generated by multi-thread.
  • static/ assets for serving webapp.py.
  • train/ 15M offline data for training whose score is under 512.
  • train12/ 3M offline data for training whose score is under 2048.
  • *.sh bash script to submit training task in server, can be neglected.
  • dataK_multi.py generate offline data by multi-thread.
  • model.py offline model.
  • modelOL.py online model.
  • modeldev.py developing model.
  • multi.py generate offline data by multi-thread.
  • test.py my script to test scores.

how to start

python test.py

LICENSE

The code is under Apache-2.0 License.

For EE369 students from SJTU only

Please read here.

About

A 2048 api for training supervised learning (imitation learning) or reinforcement learning agents

License:Apache License 2.0


Languages

Language:Jupyter Notebook 43.7%Language:JavaScript 43.5%Language:Python 5.9%Language:C++ 2.7%Language:Shell 2.6%Language:C 0.8%Language:HTML 0.4%Language:CSS 0.3%Language:Makefile 0.1%