Move Ordering
Good move ordering reduces search tree size by causing fail-highs (beta cutoffs) sooner. Typhoon's scheme:
- Hash move
- Winning captures (judged by SEE)
- Even captures (judged by SEE)
- Counter-moves
- Killer moves
- Other non-captures (ranked by history value)
- Losing captures (judged by SEE)
The hash move comes from a transposition table hit — see
Transposition Tables. Capture
moves are scored by the static exchange evaluator (SEE), which predicts
the material gain/loss of a sequence of captures without actually moving
pieces: it lists all attackers/defenders of a square and plays out the
exchange. Wrinkles: either side may opt out of the trade at any point,
pinned pieces are excluded, and newly uncovered attackers/defenders
are accounted for after each stage — slower than some SEEs, but more
accurate. The core routine, GetAttackers, is coded in x86
assembly for speed (see
x86.asm),
with a C fallback in
see.c.
Killer moves are the familiar dynamic ordering idea: good moves (refutations / beta cuts) at a given ply are stored and tried sooner at other nodes of the same ply, on the theory that a crushing response on one branch may prove crushing again on a sibling branch. Typhoon's killers are non-capturing only; mate-threatening responses to null moves get added to the killer lists too, and killers from both the current ply and current ply + 2 are considered.
The history heuristic increases a per-move counter whenever that move causes a beta cutoff, by an amount related to remaining search depth — don't confuse it with "history pruning," a different idea that estimates a move's likelihood of failing high and reduces search depth below moves unlikely to cut off.
Typhoon searches losing captures (by SEE) last. A few dynamic tweaks round things out: non-capturing moves of an en-prise piece are tried sooner; non-capturing moves to enemy-controlled squares are deferred; productive captures of an en-prise piece are tried sooner within the winning-captures group; and checking moves get a small bonus over non-checking moves of equal value.
The full move-scoring code lives in routines like
_ScoreAllMoves, _ScoreQSearchMovesInclChecks,
and _ScoreQSearchMovesNoChecks in
generate.c,
which call the SEE in
see.c.