Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Implement in Python. No additional parameters can be added to the methods but additional functions can be created and called in the given methods. Problem:
Implement in Python. No additional parameters can be added to the methods but additional functions can be created and called in the given methods.
Problem: The Reversi Game Reversi is a 2-player game, played on an 8 x 8 board. Players take turns placing their disks on the board with their assigned colour (Black and White). Black is the first player to move. A player may place their disk anywhere on the board, as long as it surrounds a group of the opponents disks (vertically, horizontally, or diagonally) on opposite sides. Any disks that you surround will become yours and will flip over to your colour. The game is over when the player to move has no possible legal move. Example: The board must always start off as such Example: The board must always start off as such 8 1 23 4567 BLACK is the first to move. BLACK must place a piece such that at least one straight (vertical, horizontal, or diagonal) line is made with another BLACK piece, with at least one White piece between and no empty spaces allowed. The available moves BLACK can make are denoted with 0 1 2 3 4 5 6 7 Task 1 Your task will be to design a Reversi class, and use the class to play games. The class will store the state of the game, and have methods to allow the players to interact with the game. We require the following methods to be implemented: wCarie Create the game state so players can play again -getScore (colour) return the current score for the player with colour 'colour - setPlayerColour (colour): set the colour for the human player to the designated colour 'colour', as well as the computer will have the other colour displayBoard()print a visual representation of the board at the current state. The row and column index should be printed on the left and top side to make it easier to check moves. See the above output as an example is Positionvalid ( ition, colour: Check if the input position position is valid for the given player colour to make. A position is defined as valid using the rules above. GameOver {): return true if the game is over, false otherwise. The game is over when the current player cannot make any more legal moves makeMovePlayer (position: Make the move given by position' for the human player. This function should also handle the capturing of pieces makeMoveNaive This function should make a naive (no strategy involved) move for the computer. This can be the first valid move when scanning the board left to right, starting at the top makeMoveSmart : This function should make a smart (strategy involved) move for the computer. This is where you can try and make your game computer as smart as possible! A good starting place can be to make the move which maximizes the computer's score. Do not forget to test your class in isolation before you write the code of the game itself. Test your class. The number of required methods may seem like a lot, but many of these methods are quite small, and are designed so that interacting with the class is easier. A skeleton template class has been provided with comments as to what is expected for each method, as well as a text file of sample output and input. Task 2 n addition, you will be required to create a main( function in a fille main.py that will create a Reversi object, and play games. You should get and process the users input, determine If the move is valid make the move, and display the updated board and score. Don't forget to validate any input from the user. Also, the game should ask whether you as the user would like to play as white or black. At the end of the game, the user should be asked whether they would like to play again. Problem: The Reversi Game Reversi is a 2-player game, played on an 8 x 8 board. Players take turns placing their disks on the board with their assigned colour (Black and White). Black is the first player to move. A player may place their disk anywhere on the board, as long as it surrounds a group of the opponents disks (vertically, horizontally, or diagonally) on opposite sides. Any disks that you surround will become yours and will flip over to your colour. The game is over when the player to move has no possible legal move. Example: The board must always start off as such Example: The board must always start off as such 8 1 23 4567 BLACK is the first to move. BLACK must place a piece such that at least one straight (vertical, horizontal, or diagonal) line is made with another BLACK piece, with at least one White piece between and no empty spaces allowed. The available moves BLACK can make are denoted with 0 1 2 3 4 5 6 7 Task 1 Your task will be to design a Reversi class, and use the class to play games. The class will store the state of the game, and have methods to allow the players to interact with the game. We require the following methods to be implemented: wCarie Create the game state so players can play again -getScore (colour) return the current score for the player with colour 'colour - setPlayerColour (colour): set the colour for the human player to the designated colour 'colour', as well as the computer will have the other colour displayBoard()print a visual representation of the board at the current state. The row and column index should be printed on the left and top side to make it easier to check moves. See the above output as an example is Positionvalid ( ition, colour: Check if the input position position is valid for the given player colour to make. A position is defined as valid using the rules above. GameOver {): return true if the game is over, false otherwise. The game is over when the current player cannot make any more legal moves makeMovePlayer (position: Make the move given by position' for the human player. This function should also handle the capturing of pieces makeMoveNaive This function should make a naive (no strategy involved) move for the computer. This can be the first valid move when scanning the board left to right, starting at the top makeMoveSmart : This function should make a smart (strategy involved) move for the computer. This is where you can try and make your game computer as smart as possible! A good starting place can be to make the move which maximizes the computer's score. Do not forget to test your class in isolation before you write the code of the game itself. Test your class. The number of required methods may seem like a lot, but many of these methods are quite small, and are designed so that interacting with the class is easier. A skeleton template class has been provided with comments as to what is expected for each method, as well as a text file of sample output and input. Task 2 n addition, you will be required to create a main( function in a fille main.py that will create a Reversi object, and play games. You should get and process the users input, determine If the move is valid make the move, and display the updated board and score. Don't forget to validate any input from the user. Also, the game should ask whether you as the user would like to play as white or black. At the end of the game, the user should be asked whether they would like to play againStep 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