https://github.com/rlch/ch0ss
A sad excuse for a Chess AI using a CNN value function and Minimax alpha-beta pruning
https://github.com/rlch/ch0ss
chess chess-ai chess-engine cnn-classification machine-learning minimax-alpha-beta-pruning python3
Last synced: 3 months ago
JSON representation
A sad excuse for a Chess AI using a CNN value function and Minimax alpha-beta pruning
- Host: GitHub
- URL: https://github.com/rlch/ch0ss
- Owner: rlch
- Created: 2021-01-02T15:07:44.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-01-05T06:47:29.000Z (over 4 years ago)
- Last Synced: 2025-01-16T22:47:07.450Z (5 months ago)
- Topics: chess, chess-ai, chess-engine, cnn-classification, machine-learning, minimax-alpha-beta-pruning, python3
- Language: Python
- Homepage:
- Size: 35.4 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ch0ss
```
oooo .oooo.
`888 d8P'`Y8b
.ooooo. 888 .oo. 888 888 .oooo.o .oooo.o
d88' `"Y8 888P"Y88b 888 888 d88( "8 d88( "8
888 888 888 888 888 `"Y88b. `"Y88b.
888 .o8 888 888 `88b d88' o. )88b o. )88b
`Y8bod8P' o888o o888o `Y8bd8P' 8""888P' 8""888P'
```A sad excuse for a Chess AI, written to justify spending more time on my hopeless addiction
## Training Set
Trained on the [KingBase2019](https://archive.org/details/KingBase2019) dataset (2.2m+ games of players with 2000+ ELO). Aggregated into one file with this scriptkiddie nonsense:
```bash
[ ! -f dataset.pgn ] && cat *.pgn | sed '/\[.*\]/d' | tr -s '\n\r' | uniq > dataset.pgn || echo dont be greedy
```## Value Function
The board state is valued by a fairly standard CNN. Feature extraction on the `n⨯6⨯8⨯8` design matrix is done through `Conv2D` layers, and classification through `Dense` layers to get a response in the range `[-1, 1]`. No pooling layers were used with the interest of retaining data - don't want the AI to end up with terrible board vision like me :upside_down_face:
## Move Selection
With help from [python-chess](https://github.com/niklasf/python-chess) (getting valid moves + parsing PGNs), valid moves from a given position are searched using the minimax algorithm with alpha-beta pruning.