Intelligent systems lecture 2

Threat Analysis
to Reduce the Effects of
the Horizon Problem in Shogi
Reijer Grimbergen
Department of Information Science
Saga University
PYIWIT'02
1
Presentation Outline
Game programming
Time limits and the horizon effect
Pruning and extension techniques
Threat analysis in two-player games
Application to shogi
Implementation issues
Preliminary results
Conclusions and future work
PYIWIT'02
2
Game Programming
Definitions
Two-player perfect information games
Only two players involved
Game state is fully accessible to both players
Goal: win the game against all the possible
replies of the opponent
PYIWIT'02
3
Game Programming
Search vs. knowledge
Two basic approaches for game programming
Search
Knowledge
Problem of search: impossible to search to the end
of the game
Search space of chess is 3580  10123
Problem of knowledge: expert knowledge is hard
to capture
PYIWIT'02
4
Time Limits and the Horizon Effect
Search in games
Search in games:
Most successful method
Decisions have to be made under strict time constraints
Basic search method is iterative deepening
Search with increasing nominal search depth
Use an evaluation function to estimate the probability
of winning
Horizon effect: no way of knowing what will
happen beyond the nominal search depth
PYIWIT'02
5
Pruning and Extension Techniques
Example
Starting position
Pruning
Nominal
search depth
Extensions
PYIWIT'02
6
Pruning and Extension Techniques
Research objective
Merits of pruning and extensions
Pruning saves time
Extensions improve reliability
Risks of pruning and extensions
Important moves are discarded
Meaningless extensions can be costly
For each game, careful tuning is vital
PYIWIT'02
7
Pruning and Extension Techniques
Practical use
Pruning and extensions in chess
Futility pruning: search is terminated when it is
unlikely to recover from a material loss
Quiescence search: play out captures beyond the
nominal search depth
Doesn’t carry over to other games
Research Objective
Construct a general framework for
pruning and extension decisions
PYIWIT'02
8
Threat Analysis
General idea
Idea
Pruning and extension decisions
should be based on threats
The problems that the search is facing
PYIWIT'02
9
Threat Analysis
Definitions
Assume two players B and W (B to move first)
A set of threats
   T1 , T2 ,, Tn

A partial order  on the set of threats
If (Ti) > (Tj) then Ti has a higher priority than Tj
Two sets of unresolved threats
    B , W  where
 δ , δ ,, δ ,, δ , δ ,, δ   and
  μ , μ ,, μ ,, μ , μ ,, μ  
B 
W
11
11
12
12
1q1
x1
1r1
PYIWIT'02
y1
x2
y2
xq v
yrw
10
Threat Analysis
Definitions
 Bi : the set of threats against B at search
depth i
W : the set of threats against W at search
depth i
Maximum operator Γ
U B  Bi   U 
i
i
1B and 1W : initial threat sets against B and W
PYIWIT'02
11
Threat Analysis
General goals
Safety
B  0
All threats against player B are resolved
Control
T W U  B T   U 
There is a stronger threat against W than any of the
threats against B
Problem: how to judge that a threat is resolved?
Search is still needed to resolve threats
PYIWIT'02
12
Threat Analysis
Pruning rules
Pruning rule 1
 BN 1   BN  T B U B T  U
N 1
N
Prune all moves at search depth N-1 (N is the nominal
search depth) that do not resolve any threats
Pruning rule 2
TW T    Bi 
i
Prune all moves at depth i that introduce threats against
W with a lower priority than the highest priority threat
against B
PYIWIT'02
13
Threat Analysis
Extension rules
Extension rule 1
 
    BN
1
B
Extend the search if the highest priority threat
of the initial set is still unresolved
Extension rule 2
 BN   β
Extend the search if the highest priority threat
extends a certain threshold
PYIWIT'02
14
Threat Analysis
Extensions
Empty the threat stack
 BN   WN 
IF
THEN execute  BN 
ELSE defend against  WN
 
PYIWIT'02
15
Threat Analysis in Shogi
Features of shogi
Pieces captured from the opponent can be re-used
Evaluation is a combination of
material, attack and defense
The assumptions behind futility pruning and
quiescence search do not apply in shogi
PYIWIT'02
16
Threat Analysis in Shogi
Threat set
   Tmin , M1 ,, M 7 , K1 ,, K 4 , Tmax 
Tmin : no threat
M1,…M7: material threats
Capture of a pawn, lance, knight, silver, gold, bishop or
rook
K1,…,K4: threats against the king.
Based on the attack and defense of the eight squares
around the king
Tmax: maximum threat, i.e. threat to capture the
king
PYIWIT'02
17
Threat Analysis in Shogi
Partial order of threats
Tmax
M6
M7
K4
M4
M5
K3
M2
M3
K2
M1
K1
Tmin
PYIWIT'02
18
Threat Analysis in Shogi
Implementation issues
Partial implementation in the shogi program
SPEAR
Both of the pruning rules
Neither of the extension rules
A static search extension to empty  B and W
N
N
PYIWIT'02
19
Results
Tactical problem test
300 tactical problems from Shukan Shogi
Compare the performance of a program without
threat analysis (NTA) to a program with threat
analysis (TA)
60 seconds per problem on an Athlon 1.2GHz
standard PC
Version
Solved
%
Total Time
NTA
100
34%
2:52:00
TA
107
36%
2:54:16
PYIWIT'02
20
Conclusions and Future Work
Preliminary results indicate that threat analysis
might improve the tactical ability of a shogi
program
A full implementation of the method is needed to
further investigate the merits of the method
Self-play experiments are needed to establish
whether the improved tactical ability is actually
leading to an improvement in playing strength
PYIWIT'02
21