Game Development Reference
In-Depth Information
15 - Reversi
Figure 15-5: White's second move
at 3, 6 will flip two of black's tiles.
Figure 15-6: The board after white's second move.
As you can see, each player can quickly grab a majority of the tiles on the board in just
one or two moves. Players must always make a move that captures at least one tile. The
game ends when a player either cannot make a move, or the board is completely full. The
player with the most tiles of their color wins.
The basic strategy of Reversi is to look at which move would turn over the most tiles.
But you should also consider taking a move that will not let your opponent recapture many
tiles after your move. Placing a tile on the sides or, even better, the corners is good because
there is less chance that those tiles will end up between your opponent's tiles. The AI we
make for this game will simply look for any corner moves they can take. If there are no
corner moves available, then the computer will select the move that claims the most tiles.
You can learn more about Reversi from Wikipedia: http://en.wikipedia.org/wiki/Reversi
Sample Run
Notice that our version of Reversi doesn't use black and white tiles because the text that
our program creates will always be the same color. Instead, we will use X's and O's to
represent the human and computer players.
Welcome to Reversi!
Do you want to be X or O?
x
The player will go first.
1 2 3 4 5 6 7 8
+---+---+---+---+---+---+---+---+
| | | | | | | | |
Search WWH ::




Custom Search