{"id":17968479,"url":"https://github.com/thomasahle/fastchess","last_synced_at":"2025-07-13T19:34:47.220Z","repository":{"id":55112236,"uuid":"122670976","full_name":"thomasahle/fastchess","owner":"thomasahle","description":"Predicts the best chess move with 27.5% accuracy by a single matrix multiplication","archived":false,"fork":false,"pushed_at":"2021-03-09T21:19:32.000Z","size":66886,"stargazers_count":95,"open_issues_count":8,"forks_count":13,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-20T01:06:05.413Z","etag":null,"topics":["ai","chess","chess-ai","chess-engine","fasttext","machine-learning","machinelearning"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thomasahle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-23T20:47:05.000Z","updated_at":"2025-02-19T00:02:53.000Z","dependencies_parsed_at":"2022-08-14T12:20:41.640Z","dependency_job_id":null,"html_url":"https://github.com/thomasahle/fastchess","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasahle%2Ffastchess","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasahle%2Ffastchess/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasahle%2Ffastchess/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasahle%2Ffastchess/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomasahle","download_url":"https://codeload.github.com/thomasahle/fastchess/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245444223,"owners_count":20616342,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","chess","chess-ai","chess-engine","fasttext","machine-learning","machinelearning"],"created_at":"2024-10-29T14:40:24.827Z","updated_at":"2025-03-25T10:32:11.881Z","avatar_url":"https://github.com/thomasahle.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Teaching FastText to play Chess\n===============================\n\nFastChess is a chess engine predicting the next move using the http://fastText.cc text classification library.\nIn 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.\n\nThe 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.\n\nYou can play against FastChess on Lichess: https://lichess.org/@/fastchess-engine (requires log-in).\nIt's current rating (January 2021) is 2052 Bullet and 1901 Blitz.\n\nScreenshot\n==========\n\n![Screenshot](https://raw.githubusercontent.com/thomasahle/fastchess/master/static/screenshot.png)\n\nRun it!\n=======\n\nYou'll need the following libraries:\n\n    pip install git+https://github.com/facebookresearch/fastText.git\n    pip install git+https://github.com/niklasf/python-chess.git\n    pip install numpy\n\nAfterwards you can play by\n\n    $ python play_chess.py\n    Do you want to be white or black? white\n      8 ♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜\n      7 ♟ ♟ ♟ ♟ ♟ ♟ ♟ ♟\n      6\n      5\n      4\n      3\n      2 ♙ ♙ ♙ ♙ ♙ ♙ ♙ ♙\n      1 ♖ ♘ ♗ ♕ ♔ ♗ ♘ ♖\n        a b c d e f g h\n\n    Your move (e.g. Nf3 or d2d4): e4\n\nTo disable MCTS and play directly against the fastText model, add the `-no-mcts` argument.\nSee `python play_chess.py --help` for more options. \n\nTrain the model\n===============\n\nThere are two ways to train the model.\nThe first one is to download a set of pgn files, like https://storage.lczero.org/files/training_pgns/ and run\n\n    python proc.py 'ccrl/**/*.pgn' -test proc.test -train proc.train\n    fasttext supervised -input proc.train -output proc.model -t 0 -neg 0 -epoch 1\n    fasttext test proc.model.bin proc.test 1\n    mv proc.model.bin model.bin\n    python play_chess.py -selfplay\n\nThe other way is to generate your own data, e.g. using stockfish.\nYou can train your own model as:\n\n    python make_data.py -games 1000 | shuf \u003e g1000\n    /opt/fastText/fasttext supervised -input g1000 -output model -t 0 -neg 0 -epoch 4\n\nAnd then run the program as:\n\n    python play_chess.py model.bin\n\nYou can also generate more data by self-play (as default games are generated by stockfish)\n\n    python make_data.py -games 1000 -selfplay model.bin \u003e games\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasahle%2Ffastchess","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomasahle%2Ffastchess","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasahle%2Ffastchess/lists"}