CMPSC 16 Final Project (Reversi / Othello)
In the game of Reversi (also known as Othello), the gameboard is an 8x8 grid.
There are 2 players (white and black). The initial configuration is shown below (Fig 1).
In the game, white (Player one) moves first. A valid move must neighbor a piece from the other team, and evetually "connect" to a piece of the same color. All of the opposing teams pieces will be flipped and will now become the color of the player who made the move. Figure 2 shows valid moves for white after 1 move.
The offical rules can be found here.

``````Gameboard:
0 1 2 3 4 5 6 7
.-----------------.
0 |                 |
1 |                 |
2 |                 |
3 |       ● ○       |
4 |       ○ ●       |
5 |                 |
6 |                 |
7 |                 |
'-----------------'``````

Fig.1 Initial gameboard.

``````
0 1 2 3 4 5 6 7
.-----------------.
0 |                 |
1 |                 |
2 |         X       |
3 |       ● ○ X     |
4 |     X ○ ●       |
5 |       X         |
6 |                 |
7 |                 |
'-----------------'
``````

Fig.2 Valid moves for white (Player 1).

``````
Game over!
0 1 2 3 4 5 6 7
.-----------------.
0 | ● ● ● ○ ○ ○ ○ ○ |
1 | ○ ○ ○ ● ○ ○ ○ ○ |
2 | ○ ○ ● ○ ○ ○ ○ ○ |
3 | ○ ○ ● ○ ○ ○ ○ ○ |
4 | ○ ○ ● ○ ○ ○ ○ ○ |
5 | ○ ● ○ ○ ○ ○ ○ ○ |
6 | ● ○ ○ ○ ○ ○ ○ ○ |
7 | ○               |
'-----------------'

Player 2 wins! (48 - 9)
``````

Fig.3 The game ends when there are no more valid moves for either player, and the score is simply the number of pieces that each player has on the board.

1. You must initialize a gameboard and print it out to the terminal (See Fig. 1).
(Hint: You will likely want to use a multi-dimensional array where 0 indicates an open cell, 1 indicates player 1's piece, and 2 indicates player 2's piece)

2a. You then must identify on all non-diagonal moves that are possible for each player, i.e., left, right, up, down. (See Fig. 2.)

2b. To adhere to the offical rules, we must also identify all diagonal moves that are possible for each player, i.e., up-left, up-right, down-left, down-right. (See Fig. 2.)

3a. Make the game interactive, prompt input from each player, and allow them to play.

``````
0 1 2 3 4 5 6 7
.-----------------.
0 |                 |
1 |                 |
2 |         X       |
3 |       ● ○ X     |
4 |     X ○ ●       |
5 |       X         |
6 |                 |
7 |                 |
'-----------------'

Player 1, make a move (x y):4 2
0 1 2 3 4 5 6 7
.-----------------.
0 |                 |
1 |                 |
2 |         ● X     |
3 |       ● ●       |
4 |       ○ ● X     |
5 |                 |
6 |                 |
7 |                 |
'-----------------'

Player 2, make a move (x y):5 4
0 1 2 3 4 5 6 7
.-----------------.
0 |                 |
1 |                 |
2 |         ●       |
3 |       ● ●       |
4 |       ○ ○ ○     |
5 |     X X X X X   |
6 |                 |
7 |                 |
'-----------------'
``````

3b. Invalid moves should not be allowed!

``````
Player 1, make a move (x y):1 1
Invalid move (1,1), try again.
0 1 2 3 4 5 6 7
.-----------------.
0 |                 |
1 |                 |
2 |         ●       |
3 |       ● ●       |
4 |       ○ ○ ○     |
5 |     X X X X X   |
6 |                 |
7 |                 |
'-----------------'

Player 1, make a move (x y):
``````

4. (Extra Credit) Create a computer player and allow the game to be human vs. human or human vs. computer.

Printing the initial board: 10%
Printing the board with possible moves for a player: 10%
Properly flipping pieces: 10%
Fully interactive 2 player game: 10%
Enabling diagonal moves: 10%
Ending the game properly (neither player has a move): 10%
Written Report: 20%
Code style: 20%
Computer player: +10% (Extra)

Example

``````
\$ cd /cs/student/cspensky/cs16/reversi/
\$ ./reversi
Gameboard:
0 1 2 3 4 5 6 7
.-----------------.
0 |                 |
1 |                 |
2 |                 |
3 |       ● ○       |
4 |       ○ ●       |
5 |                 |
6 |                 |
7 |                 |
'-----------------'

0 1 2 3 4 5 6 7
.-----------------.
0 |                 |
2 |         X       |
1 |                 |
3 |       ● ○ X     |
5 |       X         |
4 |     X ○ ●       |
6 |                 |
7 |                 |
'-----------------'

Player 1, make a move (x y):
``````
Feel free to play around for reference, although it may not be 100% error free. Use at your own risk.

References
mit.edu
ycp.edu