Code Monkey home page Code Monkey logo

chess's Introduction

Chinese chess bot training.

The bot is supposed to be trained with reinforcement learning.

Structural overview

model.py: defines the NN model. Currently it's Conv2D + Dense with max pooling and dropouts
agent.py: defines the self-play agent.
train.py: trains the model.
          python train.py    # trains from gen 1
          python train.py <your generation> # trains from the generation. Plz ensure model_<your generation>.h5 is present.
debug_test.py: tests the bot. 
          python debug_test.py <model1.h5> <model2.h5> # compares model1 (red) vs model2 (black)
visualize.py: visualize a game for debug purpose.
          python visualize.py 1/0_1.h5   # visualize moves in gen 1, game 0, player red (1). Note that 0_2.h5 is the black player but the
                                         # board still shows red. It's recorded from red side perspective.
                                         # In the visualization tool, use LEFT ARROW and RIGHT ARROW to navigate.
chess_types.py: defines basic pieces functionalities and rules.
chess_types_unittest.py: tests the functionalities

The bot depends on Keras (preferrably with tensorflow backend), h5py and pygame (for visualization).

Tuning Params:

Learning rate, batch size, epochs:  train_batch function in agent.py
Randomness: clip_probs function in agent.py
Number of game plays for each training: __main__ in train.py
Rewards: self_play function in train.py. Currently it's rather naive: +1 for each step that leads to winning. -1 for each step that leads to failing. -2 for the last step for losing to prevent bot from committing suicide.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.