/chess-ai

Training a neural net to play chess with PyTorch and the python-chess library

Primary LanguagePython

Training a Toy Neural Net to Play Chess

Having recently finished reading Deep Thinking by Garry Kasparov; this program will aim to explore some of the ideas he defines as Type A and Type B chess programs which I thought were interesting to think about - type A being a brute force approach, type B being an approach focused on an intelligent choice of move. The main aim here is to:

  1. Formulate a tree data structure for move-searching, and;
  2. Utilise a NN to collapse the search tree formulated in (1) based on historical games from a database of PGN chess games (which I've taken from https://database.lichess.org).

This model uses the python-chess library, which is an excellent resource for any similar projects, recommended highly. I also use PyTorch for the neural network. PyTorch is killer, use it!

Current state: In progress. Logging added, some colour schemas, design needs to be finished then the model could possibly deployed properly. Some minor bug fixes to come, any help is welcome.

Other cool stuff discussed on the way to completing this project:

Install/Run

 pull down the repo
 # Install dependencies:
 pip install torch torchvision numpy flask python-chess termcolor halo pickle
 # Then run it:
 python play_game.py

and Flask opens on http://127.0.0.1:5000/