Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Reversi is a strategy board game for two players, played on an 88 uncheckered board. There are sixty-four identical game pieces called disks (often spelled

Reversi is a strategy board game for two players, played on an 88 uncheckered board. There are sixty-four identical game pieces called disks (often spelled "discs"), which are light on one side and dark on the other. Players take turns placing disks on the board with their assigned color facing up. During a play, any disks of the opponent's color that are in a straight line and bounded by the disk just placed and another disk of the current player's color are turned over to the current player's color. The object of the game is to have the majority of disks turned to display your color when the last playable empty square is filled. For this program, you will be given a board with both black and white disks already placed on it. You need find the best location to place another white disk, as well as the score (white disks - black disks) that will be result. For example, white disk A is already in place on the board. By the placement of white disk B, the black row of disks has been outflanked. A disk may outflank any number of opposing disks in one or more rows. (A row may be one disk or many disks in a straight line. A disk may outflank in any direction: horizontal, vertical, diagonal, forward or backward. A disk may outflank in any number of directions at the same time. (Theoretically, it is possible to flip in up to 8 directions at once.) DISKS MAY ONLY BE FLIPPED AS A DIRECT RESULT OF A MOVE. Input The first line of input begins with two positive integers n and m, 0 < n + m < 64 separated by a single space. The value of n represents the number of white disks currently on the board, and m represents number of black disks on the board. The next n lines will contain 2 integers separated by a single space, indicating the row and column of a white disk. The remaining m rows will contain 2 integers (again separated by a single space), indicating the row and the column of a black disk. The row and columns are numbered 0 through 7. There will always be at least 1 legal move for white. If one player can not make a valid move, play passes back to the other player. When neither player can move, the game ends. This occurs when the grid has filled up or when neither player can legally place a piece in any of the remaining squares. This means the game may end before the grid is completely filled. This possibility may occur because one player has no pieces remaining on the board in that player's color. In over-the-board play this is generally scored as if the board were full (640). Examples where the game ends before the grid is completely filled: Output Your program will output 1 line of 3 integers (each integer separated by a single space). The first two integers represent the row and column where it is best to place a white disk. The last number is the result of that placement shown as the number of total white disks - the total of black disks. If there are several locations where an additional white disk achieves the maximum number of white disks, then output the one with the minimum row number. If there are multiple columns in the smallest row number that result in the maximum number of white disks, then output the smallest such column. Code Sample class Board { char board[SIZE][SIZE]; // each square holds 'b', 'w', or ' ' public Board(){}//initializes the board to all blanks int count(char color){} // returns the number of squares containing color void set(int row, int col, char color){} // sets the square at (row, col) to color int resultOfMove(int row, int col, char color){}// returns the number of color - number of other color when a disk of color is placed at (row, col) int bestMove(int & row, int &col, char color){} // returns the max resultOfMove(row,col) when a disk of color is placed at (row, col) };

Please specify what parts of the code go into the main, header, and implementation files. Thank you!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

When does benefi t realization start?

Answered: 1 week ago