Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++. Working game of Reversi in C++ using the console window to show the playing board. Requirements: The game board must be implemented as a
C++.
Working game of Reversi in C++ using the console window to show the playing board.
Requirements:
- The game board must be implemented as a multidimensional char array of size 8 x 8. No vectors or other data structures to implement the game board. Only local variables. You must design the board so that it matches clearly visible squares as seen in the provided example below
- Player pieces will be denoted by:
- b for black
- w for white
- for empty (a single space)
- Player pieces will be denoted by:
- This program must be implemented as a class called Reversi.
- All fields you create must be private. This includes the game board array. As many fields as you may need
- You must create the following required methods in the class:
- int count (char color)
- void setDisk (int row, int col, char color)
- int resultOfMove (int row, int col, char color)
- void bestMove(int& row, int& col, int& flipped, char color)
- void printBoard ( )
- void resetBoard ( )
- Additionally, you will likely need to create additional accessory, mutator, and auxiliary methods.
- You must use a .h for the class definition and a .cpp for the method definitions separate than the .cpp file for your main function. main will have your menu logic and user prompts, etc. anything that manipulates the class however goes in your class
- You must prompt the user with dialogue stating which players turn it is.
- You must denote valid moves for the current player on the game board.
- x for valid move
- You must display a menu with the following options:
- 1) Place a disk in a square
- User will be prompt to enter two numbers between 0 and 7 for the row and col number of the square they wish to place their disk
- Reject if invalid move and display error message:
- Invalid Move: The Reason Here
- Re-prompt user with menu again
- Reject if invalid move and display error message:
- User will be prompt to enter two numbers between 0 and 7 for the row and col number of the square they wish to place their disk
- 2) See movement rules of the game
- Display the movement rules of the game
- Re-display the menu
- 3) Display possible moves
- Displays all of the possible moves on the board for the player
- x for possible move location
- Reprints the board and redisplays the menu
- Displays all of the possible moves on the board for the player
- 4) See best move
- Call a method to calculate the best possible greedy move a player can make
- A greedy algorithm is one that only looks for the current possible best outcome without regard to other information such as future potential moves or moves of the opponent.
- Your method will select the best move, which is the move that flips the most pieces to their color resulting in the largest score differential (num of player disks number of opponent disks)
- If there is a tie, select the move with the lowest possible row and col numbers
- e.g. if move 1, 2 ; 5, 7 ; and 6, 1 all result in a +3 differential
- then output: Your best move is: 1, 2 and will result in a +3 score differential.
- e.g. if move 1, 2 ; 5, 7 ; and 6, 1 all result in a +3 differential
- re-display the menu
- If there is a tie, select the move with the lowest possible row and col numbers
- 1) Place a disk in a square
- When the game ends, display the winner and the score
- Congrats the Light Player has Won the Game! # - #
- Congrats the Dark Player has Won the Game! # - #
- Ask if the player would like to play again
- Restart the game if y
- Display message Thank you for playing! if n
Thank you for your hard work. Much love.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started