15.12.2012 Views

Bayesian Programming and Learning for Multi-Player Video Games ...

Bayesian Programming and Learning for Multi-Player Video Games ...

Bayesian Programming and Learning for Multi-Player Video Games ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

3<br />

2<br />

1<br />

1<br />

Figure 2.1: A Tic-tac-toe board position, in which it is the “circles” player’s turn to play. The<br />

labeling explains the indexing (left to right, bottom to top, starting at 1) of the grid.<br />

account is described in Algorithm 1. The result of applying this algorithm to the Tic-tac-toe<br />

situation of Fig. 2.1 is exhaustively represented in Fig. 2.2. For zero-sum games (as abstract<br />

strategy games discussed here), there is a (simpler) Minimax variant called Negamax, shown in<br />

Algorithm 7 in Appendix A.<br />

Algorithm 1 Minimax algorithm<br />

function mini(depth)<br />

if depth ≤ 0 then<br />

return −value()<br />

end if<br />

min ← +∞<br />

<strong>for</strong> all possible moves do<br />

score ← maxi(depth − 1)<br />

if score < min then<br />

min ← score<br />

end if<br />

end <strong>for</strong><br />

return min<br />

end function<br />

function maxi(depth)<br />

if depth ≤ 0 then<br />

return value()<br />

end if<br />

max ← −∞<br />

<strong>for</strong> all possible moves do<br />

score ← mini(depth − 1)<br />

if score > min then<br />

max ← score<br />

end if<br />

end <strong>for</strong><br />

return max<br />

end function<br />

18<br />

2<br />

3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!