Last active
August 29, 2015 14:01
-
-
Save gaspaio/fe124cc8bb68d02b0c34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Reversi is a board game for two players: the White and the Black players. | |
The board contains 8x8 squares, like a chess board. | |
The players place black or white pieces (the stones) onto | |
the board, one piece per square. | |
Whenever one or several white pieces are "sandwiched" between 2 black pieces, | |
they are "fliped": they change color from white to black, and vice-versa. | |
Sandwiching can happen vertically, horizontally of diagonally. | |
A move is only legal if it results in at least one of the opponent's pieces being | |
flipped. | |
Multiple pieces can be flipped in the same move, | |
and a single move can flip pieces in multiple directions | |
For example, in this board, the 0s indicate the legal moves for Black: | |
1 2 3 4 5 6 7 8 | |
1 . . . . . . . . | |
2 . . . . . . . . | |
3 . . . . 0 . . . | |
4 . . . B W 0 . . | |
5 . . 0 W B . . . | |
6 . . . 0 . . . . | |
7 . . . . . . . . | |
8 . . . . . . . . | |
Same thing here: | |
1 2 3 4 5 6 7 8 | |
1 . . . . . . . . | |
2 . . . . . . . . | |
3 . . . . 0 0 0 . | |
4 . . . B W W W 0 | |
5 . . 0 W B W W 0 | |
6 . . . 0 . B . . | |
7 . . . . . . . . | |
8 . . . . . . . . | |
If the Black player moves to 4-8, the result | |
will be the following board : | |
1 2 3 4 5 6 7 8 | |
1 . . . . . . . . | |
2 . . . . . . . . | |
3 . . . . . . . . | |
4 . . . B B B B B | |
5 . . . W B W B . | |
6 . . . . . B . . | |
7 . . . . . . . . | |
8 . . . . . . . . | |
The 0s indicate the legal plays for the White player: | |
1 2 3 4 5 6 7 8 | |
1 . . . . . . . . | |
2 . . . . . . . . | |
3 . . . 0 . 0 . 0 | |
4 . . . B B B B B | |
5 . . . W B W B 0 | |
6 . . . . . B . . | |
7 . . . . . 0 . . | |
8 . . . . . . . . | |
The game always starts with the following board arrangement : | |
1 2 3 4 5 6 7 8 | |
1 . . . . . . . . | |
2 . . . . . . . . | |
3 . . . . . . . . | |
4 . . . B W . . . | |
5 . . . W B . . . | |
6 . . . . . . . . | |
7 . . . . . . . . | |
8 . . . . . . . . | |
If no move is available, the player must pass its turn and | |
his opponent continues playing. | |
The game ends when no moves are available for neither player | |
and the player with the most stones of his own color wins. | |
Your task is to implement this two player game. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment