Skip to content

merhametsize/caval-ed-bronz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

15 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŽ๐Ÿ›ก๏ธ Caval รซd Bronz - Simple Python Chess Engine

Screenshot

A lightweight Python chess engine using the python-chess library for board representation.

1. ๐Ÿค– Minimax Search with Alpha-Beta Pruning and Iterative Deepening

The primary engine is the MinimaxPlayer, which employs the Minimax algorithm to determine the optimal move for a given search depth.

  • โœ‚๏ธ Alpha-Beta Pruning: The search is dramatically accelerated by implementing Alpha-Beta Pruning, which efficiently prunes branches of the search tree that cannot possibly influence the final decision.
  • โš™๏ธ Configurable Depth: The engine is initialized with a configurable search limit (depth), defaulting to 3 half-moves.
  • ๐Ÿ”„ Iterative Deepening with Move Ordering: The engine employs a form of Iterative Deepening Search (IDS). It incrementally searches from depth 1 up to the full configured depth. This allows the results from shallower searches to be used for move ordering in deeper searches, significantly improving the performance of the Alpha-Beta Pruning.

2. ๐Ÿ“Š Static Board Evaluation

The BoardEvaluator class provides the static score for the terminal nodes of the search tree (or the non-terminal nodes at the search limit).

  • โš–๏ธ Material Value Function: The evaluation is based purely on material advantage, summing the values of all pieces on the board.
  • ๐Ÿ‘‘ Piece Values:
    • King: 20,000
    • Queen: 900
    • Rook: 500
    • Bishop: 330
    • Knight: 320
    • Pawn: 100

๐Ÿ‘ฅ Player Implementations

The project defines an abstract Player class and includes several concrete implementations for testing and competition.

๐Ÿง  Intelligent Player

  • MinimaxPlayer: The main AI, using the Minimax search algorithm with Alpha-Beta Pruning and Iterative Deepening.

๐Ÿ‘ถ Baseline Players

  • DumbCapturePlayer: A greedy opponent that implements a basic heuristic: it prioritizes moves that result in a check, followed by any capture, falling back to a random legal move only if neither of the better options exist.
  • RandomPlayer: The simplest opponent, which selects a move uniformly at random from all legal moves on the board.

๐Ÿ› ๏ธ Utilities

  • ChessMatch: A utility class to orchestrate and run a single game between any two initialized Player instances until a game outcome is reached.
  • ChessTournament: A class designed to run multiple matches (num_matches) between two players and calculate the final win/loss/draw statistics.

About

Simple Python chess engine, minimax with alpha-beta pruning and iterative deepening

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors