v2026.6.1
All Bundles
Bundle Classic AI algorithms: graph search, adversarial game search, optimization and tabular reinforcement learning (-lib ai)

Minimax

Depth-limited minimax with alpha-beta pruning over a GameState. Deterministic: ties resolve to the first move in GetMoves() order.

Example

searcher := Minimax->New(9);
best := searcher->FindBestMove(state);

Operations

FindBestMove #

Finds the best move for the player to move.

method : public : FindBestMove(state:GameState) ~ Int

Parameters

NameTypeDescription
stateGameStateposition to search

Return

TypeDescription
Intbest move id, or -1 when no moves exist

GetNodesSearched #

Gets the number of nodes evaluated by the last search.

method : public : GetNodesSearched() ~ Int

Return

TypeDescription
Intnode count

New # constructor

Constructor

New(max_depth:Int)

Parameters

NameTypeDescription
max_depthIntsearch depth limit (plies)