sunfish/sunfish.py at master · thomasahle/sunfish
chessgame-aisearchpythonminimax
Abstraction: Minimalist 500-line Python chess engine using MTD-bi search
Key points:
- Board represented as 120-character padded string; padding enables fast out-of-bounds detection
- Piece-square tables (PST) encode positional value for all 6 piece types; Pawn=100, Queen=929, King=60000
- Search uses iterative deepening MTD-bi (binary search on score) with transposition table
- Implements null-move pruning, quiescent search, internal iterative deepening (IID), and futility pruning
- Stochastic gradient descent-style stalemate handling: checks if king is capturable at depth 0
- UCI protocol compatible; designed to run under PyPy for performance
Connections: Sunfish · Github · Game Tree Search · Minimax · Iterative Deepening
Source: https://github.com/thomasahle/sunfish/blob/master/sunfish.py