Planning & Search in Rust
Esc

Loading…

↑↓ move ↵ open Esc close
Colour theme
All algorithms

Negamax

adversarial game-tree-search

Negamax computes the minimax score with one rule instead of two: every position takes its highest child score. Each score is seen from the side that moved into the position, so a child's score is negated where the view switches. Textbook negamax negates at every ply; here a score is negated only where the side to move changes, so games where one side moves several times in a row are searched correctly. It returns the same score and principal variation as minimax.

Pseudocode

algorithm Negamax(p, d, viewer)input: position p, depth d, the side viewer that moved into p (Max at the root)output: the score of p from viewer's point of viewif d = 0 or moves(p) = ∅ thenreturn oriented(evaluate(p), viewer)       ▷ evaluate scores for Max; negated for Mins ← side-to-move(p)best ← −∞for each m in moves(p) dov ← Negamax(play(p, m), d − 1, s)          ▷ every child is scored for sif v > best thenbest ← vif s = viewer thenreturn bestreturn −best                                 ▷ negate only where the side to move changes

In the crates

  • game-tree-search

    Minimax written for one side, negating a child's score only where the side to move changes.

    negamax

Lineage

Comes from

builds on Minimax

Led to

Nothing on this site.

Papers

  1. An analysis of alpha-beta pruning Donald E. Knuth, Ronald W. Moore · 1975· Artificial Intelligence introduces doi 10.1016/0004-3702(75)90019-3