JRJoshua RandallSystems. Software. Possibility.

AI DEVELOPMENT / DEDICATED BUILD

Game AI

Choose actions inside formal game rules using search, heuristics, planning, learned policies, or combinations of these methods.

What it is

Choose actions inside formal game rules using search, heuristics, planning, learned policies, or combinations of these methods.

This page separates the concept, implementation path, interactive experiment, evaluation criteria, failure modes, and sources so the topic can be studied without relying on a summary tile.

Core concepts

Architecture / workflow

  1. Implement legal state transitions before adding intelligence.
  2. Create a deterministic baseline such as random or heuristic play.
  3. Add search with a fixed depth or simulation budget.
  4. Benchmark against the baseline across many games.
  5. Inspect illegal moves, repeated states, timing, and edge cases.

Technical foundations

Evaluation checklist

Failure modes and limits

Practical build path

  1. Implement minimax on a tiny deterministic game tree.
  2. Add alpha-beta pruning and count visited nodes.
  3. Integrate a legal-move engine for a real game.
  4. Benchmark a heuristic or learned evaluator against fixed search baselines.

Primary / authoritative references

Search the Learn library for related lessons →

AUTHORED STUDY COMPANION / 3.5

Solve a small game exactly before learning it

Prerequisites. Turn-based games, terminal states and dynamic programming.

In this normal-play subtraction game, a player removes one or two stones and the player taking the last stone wins. Position zero is losing for the player to move. A positive position is winning if any legal move leads to a losing position for the opponent. The companion builds this table from small positions upward.

For five stones, taking two leaves three, a losing position. This is exact dynamic programming for a fully known game, not an RL agent and not a change to either protected portfolio game. It provides a clean baseline for a later learned policy: compare decisions against the solved state table, including losing states where no winning move exists.

Solve a small game exactly before learning it — model structure
ElementModelInterpretation
TerminalZero stonesLosing for the next player
RecurrenceAny move to a losing state?Winning-state test
PolicySelect such a moveExact model-based baseline

Predict, run, compare

States 0,3,6,… are losing. At five stones the winning move takes two; at three stones the function reports no forced-winning move.

Download executable notebooks and source Inspect source ↗

Open game.ipynb in the package. Run cells in order, compare with the reference, then change the stated input. Restart the kernel to reset.

Computed reference result — local CPU fixture
{
  "winning": true,
  "optimal_take": 2,
  "winning_states": [
    false,
    true,
    true,
    false,
    true,
    true
  ],
  "scope": "perfect-information normal-play subtraction game, take 1 or 2; exact dynamic programming"
}

This is the recorded result of the included code under the package environment. It is not a live service or device measurement.

Extend the experiment

Train a small policy against the solved opponent and report agreement by state. Do not score an arbitrary move in a losing state as a missed guaranteed win.

Check your reasoning: A losing state means:
  1. No legal move exists in every case — Three stones has legal moves but is losing.
  2. No forced win against optimal play under the rules — Correct. Every legal move gives the opponent a winning position.
  3. The program crashed — It is a valid game-theoretic result.

This is an explained self-check, not a certification of mastery.

Claim-specific sources

Reviewed 2026-10-02: this worked example and its explicit assumptions. Source links and notebook results do not establish production or hardware validation.

Explore the portfolio