replace broken AI search with negamax and alpha-beta

- fix the no-op best-score update that ignored all but the first reply
- alternate sides correctly with negamax and add alpha-beta pruning
- score terminal wins and losses above material evaluations
- treat depth zero as one ply instead of underflowing
- guard relative_score against an empty board
- add hanging-piece, recapture, terminal, and depth regression tests
This commit is contained in:
2026-10-19 19:56:37 +00:00
parent dc0ad17a95
commit dd3b918561
2 changed files with 146 additions and 51 deletions
+8
View File
@@ -29,6 +29,14 @@ The rules implemented by the engine are an 8x8 draughts variant:
- A man is promoted to a king when it reaches the opponent's back row.
- Draw rules (repetition, move limits) are not implemented yet.
## AI
The engine exposes a fixed-depth negamax search with alpha-beta pruning through
`DraughtsGame::get_best_move(max_depth)`. A depth of zero is treated as one ply.
Wins and losses dominate material scoring, and faster wins are preferred. The
search has no time or node budget and no draw/repetition detection, so choose a
modest depth for positions with many pieces.
## Requirements
- Rust 1.87 or newer. The workspace uses edition 2024.