A custom chess engine implemented in Python that utilizes the python-chess library for move validation and board state management This engine employs a Minimax algorithm with Alpha-Beta pruning and uses Piece-Square Tables (PST) for position-based evaluation
-
Search Algorithm: Implements a Minimax search with Alpha-Beta pruning to find the optimal move within a specified depth
-
Move Ordering: Optimizes the search process by ordering moves before evaluation to improve pruning efficiency
-
Evaluation System:
- Material Weighting: Assigns standard values to pieces (e.g., Pawn: 100, Queen: 900, King: 20,000)
- Piece-Square Tables (PST): Uses specialized tables to encourage pieces to occupy strategically advantageous squares
- Endgame Logic: Automatically detects endgame states to transition the King's behavior from defensive to active positioning
-
Efficiency Optimizations:
- Zobrist Hashing: Generates unique hash keys for board positions to allow for fast lookups
- Transposition Table: Stores previously evaluated positions to avoid redundant calculations
-
Dual Interface: Supports both a standard command-line interface (CLI) and the Universal Chess Interface (UCI) protocol for use with external chess GUIs
The engine applies specific evaluation mappings for every piece type to determine the "value" of a square
- Pawns: Encouraged to advance and occupy the center
- Knights: Penalized for being on the edges of the board
- Bishops: Encouraged to stay off the back rank and control diagonals
- Rooks: Incentivized to occupy the 7th rank and central files
- Kings: In the mid-game, the engine prioritizes king safety (corners); in the endgame, it shifts to a table that encourages the king to participate in the center
- Python 3.x
- python-chess library
You can run the engine in two different modes:
- Command Line Interface (CLI): Play directly against the engine in your terminal.
- You can specify the search depth using the --depth flag (default is 3)
- UCI Mode: To use the engine with a GUI (like Arena or Cute Chess), use the --uci flag -> CURRENTLY UNDER MAINTAINENCE
Good Luck!