netcan / AnimalChess

Animal Fight Chess Game(斗兽棋) written in rust.
https://netcan.github.io/2020/06/07/%E7%94%A8Rust%E5%86%99%E4%B8%80%E4%B8%AA%E6%96%97%E5%85%BD%E6%A3%8B%E6%B8%B8%E6%88%8F/
MIT License
90 stars 11 forks source link
ai alpha-beta-pruning alphazero board-game chess minmax monte-carlo-tree-search rust

Animal Chess

Animal Fight Chess Game(斗兽棋) written in rust, using Alpha-Beta-Pruning algorithm, and implement AlphaZero algorithm for training.

assets/animal_chess.png

How To Play

To win the game, one player must successfully move any animal into the Den(兽穴) of the opponent. See rules:

How To Run

It need rust nightly version.

Prerequisite

$ rustup default nightly

Play

$ git clone https://github.com/netcan/AnimalChess.git
$ cd AnimalChess
$ cargo run --release

Developing

$ sudo apt-get install python3-dev python-dev
$ pip3 install virtualenv ipython
$ cd pymodule
$ virtualenv venv
$ source venv/bin/activate
(venv) $ pip install -r requirements.txt
(venv) $ maturin develop
(venv) $ ipython
In [1]: import animal_chess_pymodule

In [2]: board = animal_chess_pymodule.Board('l5t/1d3c1/r1p1w1e/7/7/7/E1W1P1R/1C3D1/T5L w - - 0 1')

In [3]: board
Out[3]:
l #@# t
 d # c
r p w e
 ~~ ~~
 ~~ ~~
 ~~ ~~
E W P R
 C # D
T #@# L

In [4]: board.generate_all_steps()
Out[4]:
[24688,
 24673,
 24656,
 25202,
 25187,
 25185,
 25716,
 25701,
 25699,
 26230,
 26198,
 26213,
 29057,
 29042,
 29025,
 29040,
 30085,
 30070,
 30053,
 30068,
 32897,
 32880,
 34422,
 34437]

In [5]: board.move_chess(24688)

In [6]: board
Out[6]:
l #@# t
 d # c
r p w e
 ~~ ~~
 ~~ ~~
 ~~ ~~
  W P R
EC # D
T #@# L

Todo