# L5

Document Sample

```					Game Tree Evaluation

4th Feb. 2008
Scribe: Lekhendro Lisham
Game Tree
0   V

1   V                           0   V
2k levels
No. of leaves, n = 22k = 4k
0   V
1   V
0   V
0   V

0            1 1         1      0 1        1    0
Figure: A game tree with 2k levels

A deterministic algorithm to determine the number of leaves of a game tree of
height 2k will be in the order of O(n).
Examples
•                                                   V
V
Expected no. of steps = (1+ 2)/2

0               1                               0               1

Expected no. of steps = (1 + 2 )/2

V
V

0               0                                   1               1      Expected no. of steps = 2

Expected no. of steps = 2
Deterministic algorithm of Λ node in the game tree:

{

V           if (Leftchild == 0)
then
o/p is 0;
else
0       1           {
if (Rightchild == 0)
then
o/p is 0;
else
o/p is 1;
}
}
Probabilistic algorithm of Λ node in the game tree:

{
randomly pick child Є {left, right}
V                            if (child == 0)
then
o/p is 0;
else
{
0              1                                 if (otherChild == 0)
then
o/p is 0;
else
o/p is 1;
}
}

This probabilistic algorithm is an example of Las Vegas algorithm.
V
The generic algorithm for any game tree:                                   T
ComputeBitAtRoot(T) // T is the root of the game tree.
{
If T is ‘Λ’ then
{
Select c Є {T.left, T.right}
cBit = ComputeBitAtRoot(c)
left               right
if (cBit==0)
then return 0;
else
{
otherBit = ComputeBitAtRoot(otherchild);     V    V       V    V
if (otherBit ==0)
then return 0;
else return 1;
}
}
If T is ‘V’ then
{
Select c Є {T.left, T.right}
cBit = ComputeBitAtRoot(c)
if (cBit==1)
then return 1;
else
{
otherBit = ComputeBitAtRoot(otherchild);
if (otherBit ==1)
then return 1;
else return 0;
}
}

}
Theorem: The expected number of leaves checked is <= 3k.

•
V
Proof by induction:                                                        Y
Assume that the statement is true for k-1 or less.
Assume 1 was returned at X1. Then,
X1               X2

2k
Event            Expected        Probability of
number leaves      occurrence                   V   V       V        V
One sub-tree is            3 k-1           >= 0.5              2k-1
executed

Both the sub-trees       2 X 3 k-1         <= 0.5
executed

• Thus, the expected number of leaves for the above case is:
<= 3 k-1 X 0.5 + 0.5 X 2 X 3 k-1
= (3/2) X 3 k-1.
Contd…
• Assuming 0 was returned at X1, then,
Event         Expected # leaves      Probability of
Occurrence

One sub-tree is             3 k-1                  0
executed

Both the sub-trees       2 X 3 k-1                 1
executed

Expected number of leaves for this case is 2 X 3 k-1 .
Contd…
•   Evaluation of Y
•   Assume Y evaluates to 0

Event                  Expected # leaves         Probability of
Occurrence
One sub-tree is executed               2 X 3 k-1               >=0.5

Both the sub-trees executed     (3/2) x 3 k-1 + 2 X 3 k-1      <=0.5
Or, (7/2) X 3 k-1

Expected number of leaves for this case is,
<= 0.5 X 2 X 3 k-1 + 0.5 X (7/2) X 3 k-1
= (11/4) X 3 k-1
<= (12 /4) X 3 k-1
= 3 k.
Contd…
•   Evaluation of Y
•   Assume Y evaluates to 1

Event               Expected # leaves   Prob. of Occurrence

One sub-tree is executed                0
0

Both the sub-trees executed       2 X 3 k-1 X 3/2            1
Or, 3 k

Expected number of leaves for this case is 3 k.

```
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
 views: 1 posted: 10/22/2011 language: English pages: 10
How are you planning on using Docstoc?