Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chess AI

A fully playable chess game with an AI opponent, built from scratch in Python using Pygame.

Features

  • 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"

Why this project

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.

How to run

pip install -r requirements.txt
python chess_main.py

Controls

  • Click a piece, then click a destination square to move
  • Z — undo last move
  • R — reset the board

Tech

Python, Pygame, multiprocessing (for non-blocking AI search)

About

A chess game with an AI opponent built from scratch in Python and Pygame — full rule implementation plus a Principal Variation Search engine with custom positional evaluation and move-ordering heuristics.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages