Вы находитесь на странице: 1из 18

Module IV

Game Playing

Contributors to Game Playing


Charles Babbage thought to program his analytical engine to play chess. Claude Shannon described mechanisms that could be used in a program to play chess. Alan Turing described a chess-playing program. Arthur Samuel built the 1st game-playing program which was used to play checkers.

Why Games in AI Research?


Games provide a structured task in which it is very easy to measure success or failure. Games generally dont require large amount of knowledge.

Game-Playing Program

A program which behaves as an intelligence of any machine which enables it to think the best moves to increase its possibility to win the game.

Components of Game-Playing program


Game playing programs have two components:
1)Plausible move generator (PMG) Finds out all the relevant moves available at an instant. 2)Static evaluation function (SEF) evaluates all the moves generated by the plausiblemove generator.

Facts of IBMs Deep Blue


Kasparov Vs. Deep Blue, May 1997 Deep Blue is current world chess champion. Parallel processor, 8 dedicated VLSI chess chips. Can search 200 million configurations per second. Uses Minimax, alpha-beta pruning, very sophisticated heuristics. It can search up to 14 ply (i.e. pairs of moves). Uses book moves.

Search tree

Game playing strategies MinMax - Overview

Squares represent decision states (ie- after a move) Branches are decisions (ie- the move) Start at root Nodes at end are leaf nodes Ex: Tic-Tac-Toe

Unlike binary trees can have any number of children


Depends on the game situation

Levels usually called plies (a ply is one level)


Each ply is where "turn" switches to other player

Players called Min and Max

Partial Game Tree for Tic-Tac-Toe

f(n) = +1 if the position is a win for X.

f(n) = -1 if the position is a win for O.


f(n) = 0 if the position is a draw.

Minimax procedure
Create start node as a MAX node with current board configuration Expand nodes down to some depth (a.k.a. ply) of lookahead in the game Apply the evaluation function at each of the leaf nodes Back up values for each of the non-leaf nodes until a value is computed for the root node At MIN nodes, the backed-up value is the minimum of the values associated with its children. At MAX nodes, the backed-up value is the maximum of the values associated with its children. Pick the operator associated with the child node whose backed-up value determined the value at the root

Minimax Algorithm
2 2 2 7 1 8 2 7 1 1 2 2 7 1 2 2 MAX MIN 2 7 1 1 1

Static evaluator value

This is the move selected by minimax

MinMax Another Example


Maxs turn Would like the 9 points (the maximum) But if choose left branch, Min will choose move to get 3 left branch has a value of 3 3 If choose right, Min can choose any one of 5, 6 or 7 (will choose 5, the minimum) 3 9 right branch has a value of 5 Right branch is largest (the maximum) so choose that move

5 4 4

Max

Min Max

5 6 7

MinMax Another Example


Max Min Max Min

Maxs turn Circles represent Max, Squares represent Min Values inside represent the value the MinMax algorithm Red arrows represent the chosen move Numbers on left represent tree depth Blue arrow is the chosen move

Improving the performance of Minimax (Alpha Beta Pruning)


The performance of the minimax algorithm can be improved through alpha-beta pruning.
- The minimax algorithm is a way of finding an optimal move in a two player game. - Alpha-beta pruning is a way of finding the optimal minimax solution while avoiding searching sub trees of moves which won't be selected. Traverse the search tree in depth-first order At each MAX node n, alpha(n) = maximum value found so far (square) At each MIN node n, beta(n) = minimum value found so far (circle)

Note: The alpha values start at - infinity and only increases, while beta values start at + infinity and only decreases.

Вам также может понравиться