Simple chess game that you can run locally that uses STOCKFISH engine and use LLMs for game analysis.
- Download the STOCKFISH engine from stockfishchess.org and place it in the same directory as the
server.js
file. - If you have the binary file in a different directory, update the path in the
.env
file.
To run the app, execute the following commands:
pnpm install
pnpm start
- chess.js -> JavaScript library for chess move validation and check/checkmate/draw detection
- chessboard-js -> JavaScript chessboard
- stockfish engine -> UCI chess engine; Engine is run locally as a child process
- express -> Web framework for Node.js
- socket.io -> Real-time bidirectional event-based communication
- ollama -> host quantized LLM models locally
- Open WebUI -> Web-based user interface for LLM
- Play against the computer
- Analysis board with LLM running locally using ollama and Open WebUI.
The client renders the chess board using chessboardjs
. Each move is validated using chess.js
. The client sends the move to the server (using socket.io), which then sends the move to the STOCKFISH engine.
The engine calculates the best move and sends it back to the client (again using socket.io). The client renders the move on the board.
The state of the board is maintained both on the server and the client using chess.js
.
For game analysis, the current position is extracted from the client in the PGN
format and sent to the server.
The server then sends the position to the LLM model running locally using ollama.