Tic-tac-toe minimax helper. Always available as
game.ticBestMove — no
use required. Optional
use tic_ai; loads
lib/tic_ai.py, a thin shim that
re-registers the same API for demos.
#comment: board is a length-9 list; empty cells are "" (or your empty marker); #comment: ai / hu are the marks for the computer and human (e.g. "X", "O"); move.setVar(game.ticBestMove(board, "O", "X")); print.number(move);
game.ticBestMove(board, ai, hu) —
returns the best empty cell index (0–8) for the AI mark using minimax,
or a sentinel when no move is available.
Full interactive example:
examples/tic_tac_toe.spl.
Implementation: interpreter game namespace;
optional lib/tic_ai.py