Fastchess
Predicts the best chess move with 27.5% accuracy by a single matrix multiplication
Install / Use
/learn @thomasahle/FastchessREADME
Teaching FastText to play Chess
FastChess is a chess engine predicting the next move using the http://fastText.cc text classification library. In other words, it is a simple one-layer + soft-max model, taking the board state as a vector and outputting a vector of probabilities for each possible move.
The project also contains a Monte Carlo Tree Search, following by Alpha Zero, which combines with the simple linear model to provide a higher quality of play.
You can play against FastChess on Lichess: https://lichess.org/@/fastchess-engine (requires log-in). It's current rating (January 2021) is 2052 Bullet and 1901 Blitz.
Screenshot

Run it!
You'll need the following libraries:
pip install git+https://github.com/facebookresearch/fastText.git
pip install git+https://github.com/niklasf/python-chess.git
pip install numpy
Afterwards you can play by
$ python play_chess.py
Do you want to be white or black? white
8 ♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜
7 ♟ ♟ ♟ ♟ ♟ ♟ ♟ ♟
6
5
4
3
2 ♙ ♙ ♙ ♙ ♙ ♙ ♙ ♙
1 ♖ ♘ ♗ ♕ ♔ ♗ ♘ ♖
a b c d e f g h
Your move (e.g. Nf3 or d2d4): e4
To disable MCTS and play directly against the fastText model, add the -no-mcts argument.
See python play_chess.py --help for more options.
Train the model
There are two ways to train the model. The first one is to download a set of pgn files, like https://storage.lczero.org/files/training_pgns/ and run
python proc.py 'ccrl/**/*.pgn' -test proc.test -train proc.train
fasttext supervised -input proc.train -output proc.model -t 0 -neg 0 -epoch 1
fasttext test proc.model.bin proc.test 1
mv proc.model.bin model.bin
python play_chess.py -selfplay
The other way is to generate your own data, e.g. using stockfish. You can train your own model as:
python make_data.py -games 1000 | shuf > g1000
/opt/fastText/fasttext supervised -input g1000 -output model -t 0 -neg 0 -epoch 4
And then run the program as:
python play_chess.py model.bin
You can also generate more data by self-play (as default games are generated by stockfish)
python make_data.py -games 1000 -selfplay model.bin > games
Related Skills
YC-Killer
2.7kA library of enterprise-grade AI agents designed to democratize artificial intelligence and provide free, open-source alternatives to overvalued Y Combinator startups. If you are excited about democratizing AI access & AI agents, please star ⭐️ this repository and use the link in the readme to join our open source AI research team.
best-practices-researcher
The most comprehensive Claude Code skills registry | Web Search: https://skills-registry-web.vercel.app
groundhog
399Groundhog's primary purpose is to teach people how Cursor and all these other coding agents work under the hood. If you understand how these coding assistants work from first principles, then you can drive these tools harder (or perhaps make your own!).
last30days-skill
18.7kAI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary
