Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Othello (also known as Reversi) is a two-player game played on an 8x8 board similar to that used in chess or checkers. Each player chooses

Othello (also known as Reversi) is a two-player game played on an 8x8 board similar to that used in chess or checkers. Each player chooses a color (black or white), and the objective of the game is to accumulate as many pieces of your own color as possible.

How to play The game starts in the following configuration: Players alternate turns, with black moving first. A move consists of placing a piece of your color on the board in such a way that it outflanks one or more of your opponents pieces. Outflanking means creating a straight line of your opponents pieces that are bordered on both ends by your pieces. This may be done horizontally, vertically, or diagonally. Outflanking your opponents pieces flips them to your color. If a player cannot outflank any of his/her opponents pieces during a turn, s/he must forfeit that turn. A player may not pass his/her turn if any valid moves exist. The game ends when neither player is able to make a valid move. (This is guaranteed to happen when the board is full, but it may occur before that. For example, if one player manages to flip all of his/her opponents pieces before the board is full, the opponent is left with no valid moves.) The winner is the player with the higher number of pieces on the board.

Number of People: Up to 2. If you work with someone else, include both your name and your teammates name on all source code files. Only one person needs to submit the final product to eCourseware, but include a note with the submission that lists both of your names. A single move may outflank more than one line of pieces. For example, the following diagrams show what happens when white places a piece that outflanks three lines of black pieces. Outflanking applies only to the closest pair of bordering pieces. In the diagram below, blacks move will flip only the white piece labeled 1, not the other two white pieces. Outflanking cannot be chained, as illustrated in the diagrams below. Blacks move will flip only the vertical white pieces, not the horizontal ones. (Diagrams blatantly stolen ahem, borrowed from http://www.rainfall.com/othello/rules/othellorules.asp, which no longer exists!)

The Assignment Write a text-based implementation of Othello. Your program should start by displaying the initial configuration of the board as drawn above. Then allow the two players to alternate turns by placing pieces onto the board. If a player cannot make a valid move, the game should automatically forfeit the turn to the other player. The game should continue until neither player can make a valid move. Once this occurs, determine and display the winner of the game. To make things easier for you (and for the TA!), Ive already developed a basic class design for you. Your project must include the classes listed on the next page.

Class Design A Tile class to represent a single tile on the Othello board. This class should include (but is not limited to) the following parts: o Instance variables State of the tile it can be empty, black, or white o Methods Flipping the tile to the opposite color A toString method that returns how the tile should be displayed

A GameBoard class to represent the entire set of 64 tiles. GameBoard is used to store the current state of the game. This class should include (but is not limited to) the following parts: o Instance variables A 2-D array of Tile objects The number of rows and columns on the board (both of these will be 8 for this game, but you should write your code in such a way that it can easily be changed to other dimensions) o Methods A method that counts the pieces of a specific color present on the board A method that places a piece of a specific color at a specific location, flipping any appropriate pieces of the opposite color A method that determines whether a valid move exists on the board for a specific color A method that determines the current state of the game (still in progress, victory by black, victory by white, or a tie) A toString method that returns how the board should be displayed An Othello class that serves as the main client program for the game. This class should include (but is not limited to) the following parts: o Instance variables

A GameBoard object to store the state of the game A Scanner object to read user input o Methods A main method that is executed to start the game Note that all user input should be located only in the Othello class. The idea is that the core game objects (Tile and GameBoard) should be independent of the games user interface. If you wanted to make a graphical version of Othello, youd be able to use the existing classes and make changes only to the Othello class! Implement error checking on all user inputs, to the extent that was covered in COMP 1900. For example, when a player makes a move, you should prevent things like: Entering coordinates that are outside of the board Entering coordinates that already contain a piece Entering coordinates that would not result in any outflanking (this is not a valid move)

For this assignment, I must emphasize this. I need a class named Tile for representing the tiles, a GameBoard class to represent the board, and an Othello class to classify the game. All of these classes need to be under the Tile, GameBoard, and Othello named respectively. Also, there needs to be players who can actually play it, not have the game play itself automatically. I have to emphasize this because the codes I have seen try to solve this do not follow these instructions, and I need to follow them for the best outcome. 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

Recommended Textbook for

Students also viewed these Databases questions

Question

What is the principle of thermodynamics? Explain with examples

Answered: 1 week ago

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago