Combinatorial games · directed state spaces
Nim as a graph
Take counters from one pile—or make the same move by following an arrow. Every node is a position and whose turn it is; every directed edge is one legal move. An optimal computer reveals that the game is really a navigation problem through a finite graph.
01 · Game board
Take from one pile
This is the keyboard-accessible counterpart to clicking a glowing graph node.
Path through the graph
0 moves- The first move will appear here.
02 · Directed state graph
Navigate the game
Building the complete graph…
The starting node and both zero-stone end nodes are marked. Arrow keys rotate the view, plus and minus zoom, and R resets it. The bright trail records the played path. Nodes outside the directed future cone are dimmed, with past states dimmed most strongly. Highlighted neighboring nodes can be clicked as moves; keyboard users can choose the same destinations with the Legal next states control. Nim-sums are hidden on graph nodes unless they are shown with the graph display control.
The two terminal nodes include whose turn comes next: an empty board with the computer to move means Victory, because you took the last counter; an empty board with you to move means Defeat. Pile-order symmetries are folded together in the graph, so positions such as [5, 3, 1] and [1, 5, 3] share a node without changing the game.