Sie sind auf Seite 1von 12

Game Tree Department of CS & IT

1



e re T Game
A game tree is a directed graph whose nodes are positions in a game and whose
edges are moves. The complete game tree for a game is the game tree starting at
the initial position and containing all possible moves from each position.
Two-person games can also be represented as and-or trees. For the first player to
win a game there must exist a winning move for all moves of the second player. This
is represented in the and-or tree by using disjunction to represent the first player's
alternative moves and using conjunction to represent all of the second player's
moves.
Solving Game Tree

With a complete game tree, it is possible to "solve" the game that is to say, find a
sequence of moves that either the first or second player can follow that will
guarantee either a win or tie. The algorithm (which is generally called backward
induction or retrograde analysis) can be described recursively as follows
.

Game Tree Department of CS & IT
2


The diagram shows a game tree for an arbitrary game, colored using the above
algorithm

1.Color the final play of the game tree so that all wins for player 1 are colored one
way, all wins for player 2 are colored another way, and all ties are colored a third
way.
2. Look at the next ply up. If there exists a node colored opposite as the current
player, color this node for that player as well. If all immediately lower nodes are
colored for the same player, color this node for the same player as well. Otherwise,
color this node a tie.
3. Repeat for each ply, moving upwards, until all nodes are colored. The color of the
root node will determine the nature of the game.

Applications

Game trees are important in artificial intelligence because one way to pick the best
move in a game is to search the game tree using the minimax algorithm or its
variants. The game tree for tic-tac-toe is easily searchable, but the complete game
trees for larger games like chess are much too large to search. Instead, a chess-
playing program searches a partial game tree: typically as many plies from the
current position as it can search in the time available. Except for the case of
"pathological" game trees (which seem to be quite rare in practice), increasing the
search depth (i.e., the number of plies searched) generally improves the chance of
picking the best move.



Game Tree Department of CS & IT
3


Variations



Many board games share the element of trying to be the first to get n-in-a-row
Some of the variations are:
1) Misre Tic-Tac-Toe
2) Tic-Tac-Tactic
3) Nine board Tic-Tac-Toe
4) Super Tic-Tac-Toe
5) Toss across
6) Star Tic-Tac-Toe
7) Mojo, Mojo Too and Mojo 2
8) Tic-Tac-Toe on a large grid
9) Tic-Tac-Toe using list of words
10 ) Memory Tic-Tac-Toe

Game Tree Department of CS & IT
4



the player wins if the opponent gets n in a row. A 33 game is a toe - tac - In misre tic
draw.
dimensional board. Each player takes - : A new game played on a three Tic Tac Tactic
it in turns to send their ball at least half way round the curved board until it drops
down into one of the 9 indents of the 3 x 3 grid. The player wins balls by forming a
row of 3, and they can, using a rubber device, change the outcome of their ball's
path and bounce their ball to where they want. Each 3-in-a-row wins a ball of the
player. The winner is skilful enough to have won five balls off his opponent.
toe boards are themselves arranged in a 33 - tac - nine tic toe - tac - In nine board tic
grid. The first player's move may go on any board; all moves afterwards are placed
in the empty spaces on the board corresponding to the square of the previous move
(that is, if a move were in the upper-left square of a board, the next move would take
place on the upper-left board). If a player cannot move because the indicated board
is full, the next move may go on any board. Victory is attained by getting 3 in a row
on any board. This makes the game considerably longer and more involved than tic-
tac-toe, with a definite opening, middle game and endgame.
toe except that the game does not - tac - is played like nine board tic toe - tac - Super tic
end when a player wins a game on one of the small boards. Instead, the position of
the small board where that player won is marked on a 3x3 grid and a player wins
when they form 3-in-a-row on that grid.
game where players throw bean bags at a large board to toe - tac - Toss Across is a tic
mark squares.
toe game where it is played with checkers like movable - tac - is tic Star Tic Tac Toe
pieces on 33 board. Each player gets 3 pieces.The players move the pieces into
empty cells until someone wins. This adds dynamism. In addition each player gets a
special piece marked with a star. The stars can be swapped. This adds surprise.


Game Tree Department of CS & IT
5



toe game played on a 33 board with original - tac - is a tic Mojo, Mojo Too and Mojo 2
and unique movable pieces and pawns - the latter is played for points. The players
move the pieces and pawn(s) onto empty positions until someone wins.
Another variation on tic-tac-toe is played on a larger grid (say 10x10) where the
object is to get 5 in a row. The increased amount of space creates a greater
complexity.
There is a variation on tic-tac-toe that is popular in Vietnam, in which the player has
to get 5 in a row to win the game. Each player takes turns to mark "x" or "o" on the
board. The strategy is to not only block the opponent, but create chances for yourself
to form 5 in a row in any direction. The board is unlimited and has no boundary until
one wins.
The game can also be varied by limiting the number of pieces and then allowing
movement
toe. However, - tac - is played with the same rules as standard tic toe - tac - Memory tic
instead of marking moves on a piece of paper, the games is played verbally, with
each player calling out which locations they take. The most used naming convention
is referring to the locations as points as their corresponding cardinal and ordinal
points with center" referring to the middle piece. In addition to the standard win
condition, an optional lose condition may be implemented for a player that "re-
touches" an already occupied square. Due to both players trying to keep all the
board positions in memory, it may be useful for a third person keep track of the game
on paper out of view of the players.





Game Tree Department of CS & IT
6



Strategy

Optimal strategies for player X. In each grid, the shaded red X denotes the optimal
move, and the location of O's next move gives the next sub grid to examine. Note
that only two sequences of moves by O (both starting with center, top-right, left-mid)
lead to a draw, with the remaining sequences leading to wins from X.

A player can play perfect tic-tac-toe (win or draw) given they move according to the
highest possible move from the following table.


Etc... Player A
Strategy 3
Player A
Strategy 2
Player A
Strategy 1
Players
Strategy
B Wins A Wins Tie Player A
Strategy 1
A Wins Tie B Wins Player A
Strategy 2
Tie B Wins A Wins Player A
Strategy 3
Etc...
Game Tree Department of CS & IT
7


Win: If the player has two in a row, play the third to get three in a row.
Block: If the opponent has two in a row, play the third to block them.
Fork: Create an opportunity where you can win in two ways.

Block opponent's Fork

Option 1: Create two in a row to force the opponent into defending, as long as it
doesn't result in them creating a fork or winning. For example, if "X" has a corner,
"O" has the center, and "X" has the opposite corner as well, "O" must not play a
corner in order to win Playing a corner in this scenario creates a fork for "X" to win). )
Option 2: If there is a configuration where the opponent can fork, block that fork.
Center: Play the center.
Opposite corner: If the opponent is in the corner, play the opposite corner.
Empty corner: Play in a corner square.
Empty side: Play in a middle square on any of the 4 sides.

The first player, whom we shall designate "X", has 3 possible positions to mark
during the first turn. Superficially, it might seem that there are 9 possible positions,
corresponding to the 9 squares in the grid. However, by rotating the board, we will
find that in the first turn, every corner mark is strategically equivalent to every other
corner mark. The same is true of every edge mark. For strategy purposes, there are
therefore only three possible first marks: corner, edge, or center. Player X can win or


Game Tree Department of CS & IT
8


force a draw from any of these starting marks; however, playing the corner gives the
opponent the smallest choice of squares which must be played to avoid losing.
The second player, whom we shall designate "O", must respond to X's opening mark
in such a way as to avoid the forced win. Player O must always respond to a corner
opening with a center mark, and to a center opening with a corner mark.
An edge opening must be answered either with a center mark, a corner mark next to
the X, or an edge mark opposite the X. Any other responses will allow X to force the
win. Once the opening is completed, O's task is to follow the above list of priorities in
order to force the draw, or else to gain a win if X makes a weak play.
To guarantee a tie if you're "O" though, if X doesn't play center (playing a corner is
the best opening move), take center, and then a side middle. This will stop any forks
from happening. If you play a corner, a perfect "X" player has already played the
corner opposite his first and proceeds to play a 3rd corner, stopping your 3-in-a-row
and making his own fork. If " X" plays center opening move, just keep your eyes
open and he won't be able to fork you. If you are X, play a corner first. If "O" takes
center (best move for him), take the corner opposite your original, and proceed as
detailed above. If "O" plays a corner or side-middle first, you are guaranteed to win.
If corner, simply take any of the other 2 corners, and then the last. You've forked
him. If he plays a side-middle, take the only corner that his blocking won't make 2 in
a row. He'll block, but the best of the other two, you'll see which one, and you'll fork
him. The only way for X not to win is for "O" to play middle and then a side-middle.







Game Tree Department of CS & IT
9


Toe - Tac - ng Tic Solvi









Game Tree Department of CS & IT
10


Moving on from simple zero-sum games, there are a bunch of directions in which we
can go. Beyond the zero-sum property, they're built on a set of fundamental
properties:
1) the idea that no player ever has an information advantage over any other player
2)the complete payoff matrix is known by all players
3) no player gets to see the other players strategy before selecting their own
and so on
Non-zero sum games turn out to be disappointing from a game theory point of view.
Given a suitable set of restrictions, you can convert a non-zero-sum game to a zero-
sum game with an additional player. In the cases where you can't do that, you're
pretty much stuck - the mathematical tools that work well for analyzing zero-sum
games often simply don't work once you relax the zero-sum requirement.
The more interesting ways of exploring different realms of games comes when you
allow things to get more complex. This comes about when you allow a players
strategy selection to alter the game. This general takes place in a turn-taking game,
where each players strategy selection alters the game for the other player. A simple
example of this is the game of tic-tac-toe. The set of strategies of the game for a
given player at any point in time is the set of open squares on the board. Each time a
player makes a move, the game is altered for the other player.
This makes things much more interesting. The easiest way to think of it is that now,
instead of a simple matrix for the game, we end up with a tree. Each move that a
player can make creates a new game for the other player. By making each game
position a tree node, and adding children nodes for each position that can follow it,
you can build a tree describing the complete set of possible game positions, and
thus the complete set of ways that the game could play out.



Game Tree Department of CS & IT
11


As usual, it's easiest to see this with an example. At the top of this post is the game
tree for tic-tac-toe, assuming that "X" goes first.
There are really three moves that X can make initially - she can play a corner, a
center-edge, or the center. Which corner or edge she chooses is irrelevant - on an
empty tic-tac-toe game-board, due to symmetries, the corners/edges are equivalent.
If X plays the center, then the other player can choose either an edge or a corner. If
X plays an edge, the O player can play a corner adjacent to X's move; a corner not
adjacent; an adjacent edge; the opposite edge; or the center. And so on.

Algorithm
One algorithm for computing the best move is the minimax algorithm:
minimax(player,board)
if(game over in current board position)
return winner
children= all legal moves for player from this board
if(max's turn)
return maximal score of calling minimax on all the children
else (min's turn)
return minimal score of calling minimax on all the children
If the game is over in the given position, then there is nothing to compute; minimax
will simply return the score of the board. Otherwise, minimax will go through each
possible child, and (by recursively calling itself) evaluate each possible move. Then,
the best possible move will be chosen, where best is the move leading to the board
with the most positive score for player 1, and the board with the most negative score
for player 2.



Game Tree Department of CS & IT
12


gram C Pro

Das könnte Ihnen auch gefallen