A fully playable chess game with an AI opponent, built from scratch in Python using Pygame.
- Complete chess rule implementation: legal move generation, check/checkmate/stalemate detection, castling, en passant, pawn promotion
- AI opponent using Principal Variation Search (PVS) — an optimized variant of minimax with alpha-beta pruning
- Custom positional evaluation function using piece-square tables for every piece type
- Move ordering heuristics to improve search efficiency:
- Checkmate-move prioritization
- Capture-move prioritization
- History heuristic
- Killer move heuristic
- Pawn structure evaluation — isolated pawns, passed pawns, and pawn chains are factored into the AI's positional judgment, not just material count
- Move animation, move log display, and sound effects
- Runs AI search in a separate process (
multiprocessing) to keep the UI responsive while the engine "thinks"
Built to deepen my understanding of search algorithms, game state management, and performance optimization — independent of my data analytics work. It's a from-scratch implementation, not built on a chess library, including hand-written legal move generation and a custom evaluation function.
pip install -r requirements.txt
python chess_main.py- Click a piece, then click a destination square to move
Z— undo last moveR— reset the board
Python, Pygame, multiprocessing (for non-blocking AI search)