In go-moku, the following procedure determines if player "X" has a winning strategy; in other words, it determines GM. The algorithm is then shown to run in polynomial space. Assume that the position P denotes the player who will move next.
M = "On input (P), where P is a generalised go-moku position:
1. Accept if "X" is next to move and has a chance to win this turn.
2. Reject if "O" is next to move and has a chance to win this turn.
3. If "X" is next to move but cannot win this round, recursively call M on (P'), where P' is the updated position P with player "Xmarker "'s on position p and "O" is next to move, for each free grid position p.
4. Accept if one or more of these calls accepts. If none of these options are available, then reject.
5.If "O" is next to move but cannot win this turn, recursively call M on (P'), where P' is the updated position P with player "Omarker "'s on position p and "X" is next to move, for each free grid position p.
6. Accept if all of these calls accept. "Reject if one or more of these calls rejects."
The recursion stack is the only space requirement of the algorithm.
There are at most levels of recursion, and each level adds a single position to the stack utilising at most space.
As a result, the method runs in space.