0% found this document useful (0 votes)
35 views

Artificial Inteligence

The document discusses game playing and artificial intelligence. It describes how games pose well-defined search problems with large search spaces. It then summarizes techniques for game tree search including minimax search and the alpha-beta pruning algorithm to reduce search space. State-of-the-art game programs are able to defeat humans at games like chess through customized hardware, evaluation functions, and large databases.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Artificial Inteligence

The document discusses game playing and artificial intelligence. It describes how games pose well-defined search problems with large search spaces. It then summarizes techniques for game tree search including minimax search and the alpha-beta pruning algorithm to reduce search space. State-of-the-art game programs are able to defeat humans at games like chess through customized hardware, evaluation functions, and large databases.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Game Playing and AI Games are well-dened problems that are generally

interpreted as requiring intelligence to play well.

Introduces uncertainty since opponents moves can not be


determined in advance.

Search spaces can be very large. Game Playing


For chess:

-Branching factor: 35 -Depth: 50 moves each player -Search tree: 35100 nodes (~1040 legal positions) Despite this, human players do quite well without doing
much explicit search. They seem to rely on remembering many patterns.

Good test domain for search methods and development of


pruning methods that ignore portions of the search tree that do not affect the outcome.

Game Playing Problem Instance of the general search problem.


MAX (X)

Sample Game Tree (Tic-Tac-Toe)

States where the game has ended are called terminal


states.
X MIN (O) X X X X X X X X

A utility (payoff) function determines the value of terminal


states, e.g. win=+1, draw=0, lose=-1.
MAX (X) X O X O X O ...

In two-player games, assume one is called MAX (tries to


maximize utility) and one is called MIN (tries to minimize utility).
X O X MIN (O) X O X X O X ...

...

...

...

...

In the search tree, rst layer is move by MAX, next layer by


MIN, and alternate to terminal states.
TERMINAL Utility X O X O X O 1 X O X O O X X X O 0 X O X X X O O +1 ...

Each layer in the search is called a ply.

Minimax Algorithm General method for determining optimal move. Generate complete game tree down to terminal states. Compute utility of each node bottom up from leaves toward root. At each MAX node, pick the move with maximum utility. At each MIN node, pick the move with minimum utility
(assumes opponent always acts correctly to minimize utility).
MAX

Minimax Computation
3

A1
MIN
A 11 A 12

A2
2
A 21 A 22 A 23

A3
2
A 31 A 32 A 33

3
A 13

12

14

Can be performed using a depth-rst search


function MINIMAX-DECISION(game) returns an operator for each op in OPERATORS[game] do VALUE[op] MINIMAX-VALUE(APPLY(op, game), game) end return the op with the highest VALUE[op] function MINIMAX-VALUE(state, game) returns a utility value if TERMINAL-TEST[game](state) then return UTILITY[game](state) else if MAX is to move in state then return the highest MINIMAX-VALUE of SUCCESSORS(state) else return the lowest MINIMAX-VALUE of SUCCESSORS(state)

When reach the root, optimal move is determined.

Imperfect Decisions Generating the complete game tree for all but the simplest
games is intractable.

Determining Cutoff Search to a uniform depth (ply) d. Use iterative deepening to continue search to deeper levels

Instead, cut off search at some nodes and estimate


expected utility using a heuristic evaluation function.

until time runs out (anytime algorithm).

Could end in states that are very dynamic (not quiesent) in Ideally, a heuristic measures the probability that MAX will
win given a position characterized by a given set of features. which evaluation could change quickly, as in (d) below.

Sample chess evaluation function based on material


advantage: pawn=1, knight/bishop=3, rook=5, queen=9
(a) White to move
Fairly even

An example of a weighted linear function:


w1 f 1 + w2 f 2 + + wn f n

(b) Black to move


White slightly better

(c) White to move


Black winning

(d) Black to move


White about to lose

Determining Cutoff (cont) Continue quiescence search at dynamic states to improve


utility estimate.

Alpha-Beta Pruning

Frequently, large parts of the search space are irrelevant to


the nal decision and can be pruned.

Horizon problem: Inevitable problems can be pushed over


the search boundary.

No need to explore options that are already denitely worse Example: Delay inevitable queening move by pawn by
exploring checking moves.
MAX
3

than the current best option.

A1
MIN
A 11 A 12

A2
<=2
A 21 A 22 A 23

A3
2
A 31 A 32 A 33

3
A 13

12

14

Black to move

10

Alpha-Beta General Principle Consider a node n where it is Players choice of moving to


that node. If Player has a better choice m at either the parent node of n or at any choice point further up, then n will never be reached in actual play.

Alpha-Beta Algorithm

function MAX-VALUE(state, game, , ) returns the minimax value of state inputs: state, current state in game game, game description , the best score for MAX along the path to state , the best score for MIN along the path to state if CUTOFF-TEST(state) then return EVAL(state) for each s in SUCCESSORS(state) do MAX( , MIN-VALUE(s, game, , )) if then return end return function MIN-VALUE(state, game, , ) returns the minimax value of state if CUTOFF-TEST(state) then return EVAL(state) for each s in SUCCESSORS(state) do MIN( , MAX-VALUE(s, game, , )) then return if end return

Player

Opponent .. .. .. Player Opponent

Maintain two parameters in depth-rst search, , the value


of the best (highest) value found so far for MAX along any path; and , the best (lowest) value found along any path for MIN. Prune a subtree once it is known to be worse than the current or .

11

12

Effectiveness of Alpha-Beta Amount of pruning depends on the order in which siblings


are explored.

State of the Art Game Programs Chess: DeepBlue beat world champion -Customized parallel hardware -Highly-tuned evaluation function developed with expert -Comprehensive opening and end-game databases Checkers: -Samuels learning program eventually beat developer. -Chinook is world champion, previous champ held title for
40 years had to withdraw for health reasons.

In optimal case where the best options are explored rst,

time complexity reduces from O(bd) to O(bd/2), a dramatic improvement. But entails knowledge of best move in advance!

With successors randomly ordered, assymptotic bound is


O((b/logb)d) which is not much help but only accurate for b>1000. More realistic expectation is something like O(b3d/4).

Othello: Programs best players (e.g. Iago). Fairly simple ordering heuristic can produce closer to
optimal results than random results (e.g. check captures & threats rst).

Backgammon: Neural-net learning program TDGammon


one of worlds top 3 players.

Theoretical analysis makes unrealistic assumptions such


as utility values distributed randomly across leaves and therefore experimental results are necessary.

Go: Branching factor of ~360 kills most search methods.


Best programs still mediocre.

13

17

You might also like