A chess game implementation where two Google Gemini AI models play against each other, featuring unicode board visualization and interactive game replay.
-
Install dependencies:
pip install -r requirements.txt
-
Set up your Google AI API key:
- Copy
.env.example
to.env
- Add your Google AI API key to the
.env
file - Get your API key from: https://ai.google.dev/
- Copy
-
Run the game:
python main.py
Run python main.py
to access the interactive menu:
- Play new game: Start a fresh match between two AI models
- Replay saved game: Watch previous games move by move
- List saved games: See all games in your collection
- Exit: Quit the application
python main.py --play
- Start a new game directlypython main.py --replay <filename.json>
- Replay a specific gamepython main.py --list
- List all saved games
- Press Enter to advance to the next move
- Press Ctrl+C to exit the replay at any time
- Unicode Chess Board for CLI: Clear visual representation with chess piece symbols
- Interactive Game Replay: Step through saved games move by move
- Two AI Players: Gemini models play against each other with different strategies
- Full Chess Validation: Complete rule enforcement using
python-chess
- Smart Move Analysis: AI provides evaluations and explanations for each move
- Game Collection: All games saved with timestamps for future replay
- Fallback System: Handles AI errors gracefully with valid move selection
The game features a beautiful Unicode chess board display:
- Games are saved as JSON files in the
games/
directory - Filename format:
game_YYYY-MM-DD-HH-MM-SS.json
with full timestamp - Each saved game includes:
- Complete move history with explanations
- Position evaluations
- Final result
- FEN notation for each position
You can modify:
- Maximum number of moves per game (default: 100)
- AI model used (currently using
gemini-2.5-flash
) - Prompting strategy in the
create_prompt_for_ai
method