Agentic Chess AI featuring a custom NNUE engine and C# PGN pipeline. Web UI Built with Astro/React/FastAPI, it offers two modes: a standalone Lichess engine and an interactive AI web chatbot for gameplay and chatting.
- Backend: Azure VM (Containerized w/ Docker)
- Frontend: Cloudflare Pages
Available at: https://aryxenv.dev/nnue-chessbot
- Custom NNUE Engine: Implements a HalfKP architecture with dual accumulators for efficient evaluation.
- High-Performance Data Processing: Uses a dedicated C# tool (.NET 9.0) to filter massive PGN datasets (100GB+) in minutes.
- Advanced Search Engine:
- PVS (Principal Variation Search): NegaScout variant for optimal node visiting.
- Quiescence Search: Mitigates horizon effect by searching volatile positions (captures/promotions).
- Transposition Table: Zobrist hashing to cache evaluations and search results.
- Iterative Deepening: Time-managed search depth progression.
- Move Ordering: MVV-LVA, Killer Heuristic, and History Heuristic.
- Pruning & Reduction: Null Move Pruning and Late Move Reduction (LMR).
- Lichess Integration: Connects directly to Lichess via API using
lichess-bot. - Web Interface: A modern web-based chat and game interface built with Astro (Static) and React, backed by a FastAPI Python server.
engines/: Contains the chess engine implementations.bot/: The main NNUE bot (Python).- Read more
data/process_data/: The C# tool for filtering raw PGN data.chatbot/: The web-based chat and game interface (Astro/React).lib/: Shared libraries and utilities.
- Python 3.6+
- Node.js v18+ (for Web Interface)
- .NET SDK (for data processing)
- Lichess Account (for API token)
-
Clone the repository:
git clone https://github.com/aryxenv/chess-ai.git cd chess-ai -
Install Python dependencies:
pip install -r requirements.txt
-
Configure the bot:
- Copy
config.yml.exampletoconfig.yml. - Add your Lichess API token to
config.yml.
- Copy
Note
Data processing tool does not process multiple PGN files.
Before training, filter your raw PGN data using the high-performance C# tool.
- Place your raw PGN file at
data/lichess_db_raw.pgn. - Run the filter tool:
cd data/process_data dotnet run -c Release - This generates
data/elite_data/lichess_db.pgn.
Train the NNUE model using the filtered data.
- Preprocess:
python -m engines.bot.preprocess
- Train:
python -m engines.bot.train
Start the full stack (Web Interface + Engine) using the PowerShell script:
.\chess_bot_web.ps1This will check for dependencies and launch both the Astro dev server and the Python engine in separate windows. access the interface at http://localhost:4321.
Start the bot to connect to Lichess and play games.
-
Windows (PowerShell):
pwsh start_bot.ps1
-
Linux/macOS:
./start_bot.sh
MIT
- Aryan Shah - GitHub