How does this engine handle search, focus on move prioritization and when it goes to…
- User
How does this engine handle search, focus on move prioritization and when it goes to what depth especially?
Assistant
Based on the provided code from the Ethereal chess engine, I'll explain its key search and move prioritization mechanisms:
- Iterative Deepening
The engine uses iterative deepening, implemented in
iterativeDeepening(), where it:
- Starts from depth 1 and incrementally increases depth until stopping conditions are met
- Can be limited by time, depth, nodes, or run indefinitely
- Handles multiple lines of play (MultiPV) if requested
- Move Ordering/Prioritization
The engine uses a sophisticated move picker (in
movepicker.c) that prioritizes moves in this order:
code1. Transposition Table Move 2. Good Captures/Promotions (positive SEE score) 3. Killer Moves (good quiet moves that caused cutoffs at same depth) 4. Counter Moves (moves that previously countered the last move) 5. Quiet Moves (ordered by history heuristics) 6. Bad Captures (negative SEE score)- Aspiration Windows
The
aspirationWindow()function implements aspiration window search:
- Uses previous iteration's score to create a narrow alpha-beta window
- If the score falls outside the window, it re-searches with wider bounds
- Window size starts at
WindowSize(10) and expands if needed - Helps improve pruning by providing tighter bounds
- Depth Management The engine adjusts search depth based on several factors:
- Base depth from iterative deepening
- Extensions for check, singular moves, and other tactical situations
- Reductions for late moves in quiet positions (Late Move Reductions)
- Different depth requirements for different move types (e.g., captures vs. quiet moves)
- Search Termination The search can terminate based on:
- Reaching maximum depth
- Time management decisions
- Node count limits
- Finding mate
- User stop command
The move prioritization is particularly important as it helps the alpha-beta search find good moves early, allowing for more aggressive pruning of worse moves. This is implemented through the
MovePickerstructure which maintains the state of move generation and ordering throughout the search.The depth management is dynamic - while the engine does full-depth searches on promising lines, it will reduce depth for less promising moves and extend search depth for critical positions (like checks or singular moves). This allows it to search important variations more deeply while maintaining reasonable performance by reducing effort on less promising lines.
- Iterative Deepening
The engine uses iterative deepening, implemented in
- User
Explain the history heuristics.
Assistant
- User
And this is the default prioritization after cached and killer moves?
Assistant
Yes, from the
movepicker.ccode, we can see the exact order of prioritization in the move picker's stage enumeration and selection logic:c- User
Give more code quotes on this point, 5-20 lines each.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.