A NumPy-based neural network trained on human chess games to predict opening moves and model human playing preferences.
Unlike traditional chess engines that aim to find the objectively strongest move, this project explores how machine learning can reproduce patterns in human chess decision-making.
The project uses supervised learning to train a neural network on real chess games from the Lichess open source database at here: https://database.lichess.org/
Given a chess position, the network predicts a probability distribution over possible moves, learning which moves humans are more likely to choose in similar positions.
The goal is to model human playing behaviour rather than simply imitate an engine.
The network is implemented from scratch using Python and NumPy.
Architecture:
768 → 128 → 4608
| Layer | Dimensions | Description |
|---|---|---|
| Input | 768 | Flattened 12-channel chessboard encoding |
| Hidden | 128 | Learns patterns in chess positions |
| Output | 4608 | Predicts probabilities for possible moves |
The output layer supports both standard moves and pawn promotions.
- Data Collection – Uses human chess games from the Lichess rated games database.
- Data Processing – Extracts chess positions and their corresponding moves from PGN files.
- Board Encoding – Represents each position using 12 binary channels, one for each piece type and colour.
- Training – Trains the neural network using supervised learning and backpropagation, with the Adam optimiser.
- Move Prediction – Converts network outputs into probabilities and filters out illegal moves before selecting a move.
- Python 3
- NumPy
- python-chess
- Lichess game database (PGN)
- Explore neural networks through a practical chess application.
- Learn human opening preferences from real-world game data.
- Investigate how effectively a relatively simple neural network can model chess decision-making.
- Compare human move preferences with traditional engine evaluations.
- Stockfish integration for position evaluation.
- Improved model generalisation and training performance.
- Interactive chess interface.
- Natural language explanations of predicted moves.
Clone the repository:
git clone https://github.com/caerularbor/chess-network.git
cd chess-networkInstall dependencies:
pip install numpy python-chessFurther instructions for obtaining the dataset, configuring training, and running the model will be added as the project develops.