Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Types of Games
Axes:
Deterministic or stochastic?
One, two, or more players?
Zero sum?
Perfect information (can you see the state)?
Deterministic Games
Zero-Sum Games
Zero-Sum Games
General Games
Adversarial Search
(Minimax)
Minimax values:
Deterministic, zero-sum games:
computed
recursively
ma
5
x
Minimax search:
A state-space search tree
Players alternate turns
Compute each nodes minimax
value: the best achievable utility
against a rational (optimal)
adversary
5 min
Terminal
values:
part of the
game
Minimax
Minimax Implementation
def max-value(state):
initialize v = -
for each successor of
state:
v = max(v, minvalue(successor))
return v
def min-value(state):
initialize v = +
for each successor of
state:
v = min(v, maxvalue(successor))
return v
Minimax Implementation
def value(state):
if the state is a terminal state: return the
states utility
if the next agent is MAX: return maxvalue(state)
if the next agent is MIN: return min-value(state)
def max-value(state):
initialize v = -
for each successor of
state:
v = max(v,
value(successor))
return v
def min-value(state):
initialize v = +
for each successor
of state:
v = min(v,
value(success
or))
return v
Minimax algorithm
Properties of minimax
Minimax Properties
max
min
10 10
100
Resource Limits
-2
-1
-2
min
9
Example:
max
Evaluation Functions
- pruning example
- pruning example
- pruning example
- pruning example
- pruning example
The - algorithm
The - algorithm
Alpha-Beta
Implementation
: MAXs best option on path to root
: MINs best option on path to root
def max-value(state, , ):
initialize v = -
for each successor of
state:
v = max(v,
value(successor,
, ))
if v return v
= max(, v)
return v
def min-value(state , , ):
initialize v = +
for each successor of
state:
v = min(v,
value(successor, ,
))
if v return v
= min(, v)
return v
Alpha-Beta Pruning
Properties
max
min
10
10
Alpha-Beta Example
Alpha-Beta Example