Skip to main content

Module minimax

Module minimax 

Source
Expand description

Classical alpha-beta minimax (negamax formulation) for Quantik.

Searches the exact game tree using has_winning_line for terminal detection and falls back to crate::evaluation::evaluate once max_depth is exhausted. With max_depth = 16 (MinimaxEngine::solve) the search always reaches true terminal states — no Quantik game exceeds 16 plies — so it acts as an exact solver, not just a heuristic engine.

Negamax sign convention: negamax returns the value of a position from the perspective of the side to move at that node. A caller negates a child’s value to fold it back into its own perspective.

Terminal values use win - ply (not a flat win) so that a forced mate found sooner scores strictly higher than one found deeper.

State::canonical_key() collapses the D4 × S4 = 192 board symmetries without swapping colors, so the negamax value (always relative to the side to move, not a fixed color) is safe to cache/dedup by that key. Only the value/bound is ever cached — never the move — since the key alone doesn’t preserve which concrete move produced a given child.

Sibling dedup (dedup_children) and the transposition table (use_transposition_table) both key off canonical_key(). Where dedup and the TT are both active on the same call, the child key already computed by dedup is threaded into the recursive call so the TT probe does not recompute it.

Structs§

MinimaxConfig
Configuration for MinimaxEngine.
MinimaxEngine
Alpha-beta negamax search engine over the exact Quantik game tree.
MinimaxResult
Result of a MinimaxEngine::search (or .solve) call.