This project is about to building a console-mode and a GUI based two-player version of Othello that is capable of playing a single game of Othello on a single computer (Console and GUI based are seperate projects). The program begins by asking the users to choose these options:
Users will interact with your program in the following way.
The program asks the user to specify the following options, in the order specified below. As with previous projects, when users enter erroneous input (e.g., a number of rows with a fractional part, an invalid move), the program should inform the user that the input was erroneous (and how) and ask the user for the input again.
The number of rows on the board, which must be an even integer between 4 and 16.
The number of columns on the board, which must be an even integer between 4 and 16 and does not have to be the same as the number of rows.
Which of the players will move first: black or white. (Generally, the black player moves first in Othello, though we'll allow the user to specify that the white player should move first if preferred.)
According to the rules, the game begins with four discs on the board: two white and two black, arranged on the four center cells of the grid, with the two white discs separated diagonally and the two black discs separated diagonally. The user can choose which color disc will be in the top-left position of these four center cells: white (the traditional default) or black.
Finally, the user can select what it means to win the game. There are two choices:
The player with the most discs on the board at the end of the game is the winner.
The player with the fewest discs on the board at the end of the game is the winner, which makes for an interesting and different flavor of the game.
Until the game is over, the following sequence of events is repeated:
Display the score (i.e., how many discs of each color are on the board), the board, and whose turn (black or white) it is to move.
The user is asked to make a move, by specifying a cell on the board in which he or she would like to place a disc. It's up to you how a user selects a cell, though you should make it clear in your user interface what the user is required to do.
If the move is invalid (see the rules if you're curious what makes a move invalid), inform the user and ask for another one.
The move is made, discs are placed and flipped, and we're done with this move, proceeding to the next one.
When the game is over, display the score, the board, and who the winner is. Be sure to handle the case when there is no winner (i.e., the number of discs on the board for both players is equal at the end of the game).
At this point, your program can end. If you prefer, you can begin again (by asking the user to specify options again, etc.), but if you do, give the user the opportunity to exit the program if another game isn't desired.
A couple of "gotchas" to be aware of in the game logic
Sometimes, a player will make a move and, as a result, the opposite player will have no valid moves available (i.e., there is no cell in the grid in which the opposite player can move afterward). In that case, the turn reverts back to the player who just moved.
Occasionally, neither player will have a valid move on the board, even though there are still empty cells in the grid. In this case, the game immediately ends and the winner is determined based on the number of discs each player has on the board.