Game-playing is one of AI's greatest successes. We investigate the techniques through tic-tac-toe.
X | O | X --+---+-- O | X | X --+---+-- O | X | O
Classical game-playing techniques work for games with two features:
Here are some legitimate examples.
tic-tac-toe Othello checkers chess backgammon GoHere are some bad examples.
poker Stratego bridge Scrabble Boggle
We can represent a game as a game tree.
--- _____________ --- / ________ --- ____________ / / / \ \ X-- -X- --X --- --- --- --- --- X-- ... --- ___ --- --- --- --- --X / / \ / \ XO- X-O X-- O-- --- --- --- ... --- --- ... --- --- --- --O --X -OX / | \ / | \ XX- X-X X-- O-- O-- ... OX- --- --- ---
If you calculate how big this can be, you'll see that this is at must a few hundred thousand - quite tractable by today's standards.
Assign 1 to all wins for X, -1 for all wins to O, and 0 to all cat's games.
Now by working up the tree, we can calculate the value of any state by choosing the minimum if it's O's move and maximum if it's X's move.
Evaluating for all nodes is called minimax search.
-OX OXX O-- ____ [1] ____ / | \ XOX -OX -OX OXX OXX OXX O-- OX- O-X [0] [-1] [1] / \ / \ XOX XOX OOX -OX OXX OXX OXX OXX OO- O-O OX- OXO [1] [0] [-1] [0] | | | XOX XOX XOX OXX OXX OXX OOX OXO OXO [1] [0] [0]
Harder games can't be searched entirely. We use a heuristic function to estimate ``goodness'' of a board for X.
Go down as many levels as possible, evaluate heuristic function, apply minimax search to tree.
We chose the heuristic function that is -.5 if O has a row, column, or diagonal with two filled and a blank, otherwise .5 if X has this, otherwise 0.
-OX _____________ -XX _____________ / __ O-- ___ \ / / [1] \ \ OOX -OX -OX -OX -XX OXX -XX -XX O-- O-- OO- O-O [1] [1] [1] [1] / | \ / | \ / | \ / | \ OOX OOX OOX XOX -OX -OX XOX -OX -OX XOX -OX -OX XXX -XX -XX OXX OXX OXX -XX XXX -XX -XX XXX -XX O-- OX- O-X O-- OX- O-X OO- OO- OOX O-O O-O OXO [1] -.5 [1] .5 -.5 [1] -.5 [1] .5 -.5 [1] .5