One can search the full tic tac toe game tree, using only fail fast optimization of negation as failure, in less that 100ms. Thats what this solution does using a holistic representation of the game state as a single Prolog term:
?- time((init(X), best(X, x, _))).
% 92,055 inferences, 0.031 CPU in 0.031 seconds (99% CPU, 2984342 Lips)
false.
The above solution uses a single term for the board, here is an example from the code:
init([[-, -, -], [-, -, -], [-, -, -]]).
Are there any Prolog means around to solve the problem differently. Instead of using a single term that represents the state, use a set of facts to represent the state like here in a game representation from the Stanford General Game Playing.
(init (cell 1 1 b))
(init (cell 1 2 b))
(init (cell 1 3 b))
(init (cell 2 1 b))
(init (cell 2 2 b))
(init (cell 2 3 b))
(init (cell 3 1 b))
(init (cell 3 2 b))
(init (cell 3 3 b))
Was thinking about CHR: Constraint Handling Rules, since it can add and remove facts, but I dont know whether its suitable for adversarial search.