Graphics Reference
In-Depth Information
Fig. 8.3 “Empty” versus “full” detection
Fig. 8.4 “X” versus “O” detection
shapes are symmetric. So we recognize an X if the box is full of gradients, or an O
if it has little or no gradients (Fig. 8.4 ).
8.2.3 Tic-Tac-Tandroid AI
Priority-based algorithm . In order to compute the best next move from the infor-
mation deduced by the vision block, we devised a priority-based algorithm. The first
step in any zero-sum game like tic-tac-toe is to check if someone is about to win.
If the computer is about to win, then its first priority should be to play the winning
move. If it is not about to win, but the opponent is, it should try to block the opponent.
If neither the computer nor the opponent is about to win, we need a third option. The
computer should not just play randomly; then it is possible for the opponent to force
a win. To do this systematically, we dynamically assign a “priority number” to each
cell in the grid, and we pick the one with the highest priority to play in.
Search WWH ::




Custom Search