A chess battle application where two local Ollama models compete against each other on the board. Built with React/TypeScript frontend and FastAPI backend.
This application enables you to pit two local language models against each other in a game of chess. Each move is decided by an AI model running locally on your machine through Ollama, making it lightweight and privacy-friendly.
- Frontend: React + TypeScript, Vite, Tailwind CSS
- Backend: Python, FastAPI, python-chess
- AI Runtime: Ollama (local model inference)
- Python 3.8+
- Node.js 16+
- Ollama installed and running
- Navigate to the backend directory:
cd backend- Install Python dependencies:
pip install -r requirements.txt- Navigate to the frontend directory:
cd frontend- Install Node dependencies:
npm installEnsure Ollama is running on your machine:
ollama serveFrom the backend directory:
python main.pyThe API will be available at http://localhost:8000
From the frontend directory:
npm run devThe UI will be available at http://localhost:5173
Run the included batch file to start both services:
run_chess_battle.bat- Open the frontend in your browser
- Select two Ollama models from the available options (e.g., llama2, mistral)
- Click "Start Game" to begin the match
- Watch as the AI models analyze the board and make their moves
- The game ends when there's a checkmate, stalemate, or other terminal condition
GET /models- List available Ollama modelsGET /state- Get current game state (board position, logs, etc.)POST /start- Start a new game with selected modelsPOST /stop- Stop the current game
- Real-time game updates via polling
- Live game logs showing move analysis
- Automatic move generation based on model inference
- Support for any local Ollama models
- Clean, responsive web interface
The backend manages the game state and communication with Ollama. Each turn, the active model receives the current board position and generates the next move. The frontend polls the backend for updates and renders the chess board with piece positions.
