Question Details

(Solved) This project asks you to implement the game logic of Othello, along with a console-mode program with a very spartan user interface that you'll use to...


This project asks you to implement the game logic of Othello, along with a console-mode program with a very spartan user interface that you'll use to test it — and that we'll use to automatically test it, making it crucial that you get the format of the program's input and output right according to the specification below. Spacing, capitalization, and other seemingly-minor details are critical.

Using your test program, you'll be capable of playing a single game of Othello on a single computer. There are a handful of options that allow you to specify, before the game begins, how the game will be played. The program begins by reading input that selects these options; the game is then played by requiring input directly into the console that specifies a player's next move, continuing until the game is complete, at which point the program ends.

When you're finished, you'll have the game logic that will form the basis of your completed version of Othello in the next project.

A detailed look at how your program should behave

Your program will take its input via the console, printing no prompts to a user. The intent here is not to write a user-friendly user interface; what you're actually doing is building a tool for testing your game logic, which we'll then be using to automatically test your game logic. So it is vital that your program reads inputs and writes outputs precisely as specified below. You can freely assume that the input will match the specification described; we will not be testing your program on any inputs that don't match the specification.

  • Your program begins by printing a line of output specifying which of the two sets of Othello rules are supported by your program, by printing eitherFULLorSIMPLE. (See the section titledSimplified Othello rulesbelow for a description of the simplified set of rules, which you can implement for partial credit if you're unable to complete the full rules.)
    • Note that this is not a user option; this is something your program prints, before it does anything else, so we'll know (when we're grading it) how it should behave.
  • Your program then reads four lines of input, specifying the options that will be used to determine how the game will be played.
    • The first line specifies the number of rows on the board, which will be aneven integerbetween 4 and 16 (inclusive).
    • The second line specifies the number of columns on the board, which will be aneven integerbetween 4 and 16 (inclusive) anddoes nothave to be the same as the number of rows.
    • The third line specifies which of the players will move first:Bfor black,Wfor white.
    • The fourth line selects how the game is won:>means that the player with the most discs on the board at the end of the game wins,<means the player with the fewest.
  • Next, your program will read the initial contents of the board. To make it simpler to test a variety of scenarios, your game will need to support any initial arrangement of discs, so it will be necessary to read the entire contents of the board from the input. It will be appear in the input in this form:
    • Each row will occupy a single line of input, with one space separating the cells in that row. Each cell will be specified as eitherB(if a black disc is in that cell),W(if a white disc is in that cell), or.(if the cell is empty).
    • The number of rows and columns described in this way will match the number of rows and columns specified in the first two lines of the input.
    • For example, if there are 8 rows and 8 columns on the board, the initial contents of the board might appear in the input this way:
      . . . . . . . . . . . . . . . . . . . . . . . . . B W B W . . . . . . W B . . . . . . . B W . . . . . . . B . . . . . . . . . .           
  • After the initial arrangement of the board is specified in the input, the game begins, proceeding one move a time until it's complete.
    • Before each turn, the following information is printed to the console:
      • The characterB, followed by a colon and a space, followed by the number of discs on the board that are black. This is followed by two spaces, the characterW, a colon and a space, and the number of discs on the board that are white.
      • The contents of the board, with each row occupying one line of output, and one space separating each pair of cells. Each cell is written either as aB(if a black tile occupies that cell), aW(if a white tile occupies that cell), or a.(if no tile occupies that cell). For example:
        . . . . . . . . . . . . . . . . . . . . . . . . . . . B W . . . . . . W B . . . . . . . . . . . . . . . . . . . . . . . . . . .               
      • The wordTURN(in all-caps), followed by a colon and a space, followed byBif it's the black player's turn,Wif it's white's turn.
    • After printing the information above, the program reads a line of input specifying the current player's move. The move is specified as two integers on a line, separated by a space. The first integer specifies the row number (with 1 being the top row, 2 being the row below that, and so on) and the second integer specifies the column number (with 1 being the leftmost column, 2 being the one to the right of that, and so on).
      • If the move is valid, print the wordVALIDalone on a line, apply that move (i.e., make the appropriate changes to the state of the game) and then continue the game..
      • If the move is invalid (see therulesif you're curious what makes a move invalid), print the wordINVALIDalone on a line and wait for the user to specify another move.
  • At the conclusion of the game (i.e., after the last move is made and there are no more legal moves on the board), the final state of the game is printed to the console, quite similarly to how it's printed before each turn:
    • The characterB, followed by a colon and a space, followed by the number of discs on the board that are black. This is followed by two spaces, the characterW, a colon and a space, and the number of discs on the board that are white.
    • The contents of the board, in the same format described above.
    • The wordWINNER(in all-caps), followed by a colon and a space, followed byBif the black player has won,Wif the white player has won, andNONEif no player has won (i.e., the final score is tied).

The program ends when the game is over.

You are required to keep the code that implements the game logic entirely separate from the code that implements your console-mode user interface. To that end, you will be required to submit at least two modules: one that implements your game logic and another that implements your user interface. You're welcome to break these two modules up further if you find it beneficial, but the requirement is that you keep these two parts of your program — the logic and the user interface — separate.

Note that this requirement is motivated partly by a desire to build good design habits, but also by the practical reality that maintaining that separation properly will give you a much better chance of being able to reuse your game logic, as-is and without modification, in the next project, when you'll be asked to build a graphical user interface for your game. In a big-picture sense, you can think of the user interface in this project as being a "throwaway"; while we'll be using it to grade your game logic, the true goal here is the complete version of Othello with a graphical user interface. So keeping this "throwaway" code completely separate from your game logic means that it will be easy to leave it out of your completed version, without causing anything else to break.

Module naming

Exactly one of your modules must be executable (i.e., should contain an if __name__ == '__main__': block), namely the one that you would execute if you wanted to launch your console user interface and play your game. No other modules are permitted to have an if __name__ == '__main__': block. (This is so our test automation tools can automatically determine which of your modules to execute.)

Using classes and exceptions to implement your game logic

Your game logic must consist of at least one class whose objects represent the current "state" of an Othello game, with methods that manipulate that state; you can feel free to implement additional classes, if you'd like. Note that this is in stark contrast to the approach used in connectfour.py in Project #2, where we used a namedtuple and a set of functions that returned new states. Classes offer us the ability to mix data together with the operations that safely manipulate that data; they allow us to create kinds of objects that don't just know how to store things, but also to do things.

Some of the methods I found useful in my own implementation of the Othello game state are listed below; this is not an exhaustive list, and you'll probably find a need for additional methods beyond these.

  • Get the number of rows and/or columns on the board.
  • Find out whose turn it is.
  • Determine whether the game is over.
  • Determine whether a disc is in some cell in the grid; if so, determine its color.
  • Make a move.

Even if your console user interface does error checking, your game logic must not assume the presence of a particular user interface, so it must check any parameters it's given and raise an exception if the parameters are problematic (e.g., a non-existent row or column, an attempt to make an invalid move, an attempt to make a move after the game is over). Create your own exception class(es) to represent these error conditions.


I need an original answer to this problem, not an already posted answer from the website 

 


Solution details:
STATUS
Answered
QUALITY
Approved
ANSWER RATING

This question was answered on: Sep 05, 2019

PRICE: $18

Solution~000200204021.zip (25.37 KB)

Buy this answer for only: $18

This attachment is locked

We have a ready expert answer for this paper which you can use for in-depth understanding, research editing or paraphrasing. You can buy it or order for a fresh, original and plagiarism-free solution (Deadline assured. Flexible pricing. TurnItIn Report provided)

Pay using PayPal (No PayPal account Required) or your credit card . All your purchases are securely protected by .
SiteLock

About this Question

STATUS

Answered

QUALITY

Approved

DATE ANSWERED

Sep 05, 2019

EXPERT

Tutor

ANSWER RATING

GET INSTANT HELP/h4>

We have top-notch tutors who can do your essay/homework for you at a reasonable cost and then you can simply use that essay as a template to build your own arguments.

You can also use these solutions:

  • As a reference for in-depth understanding of the subject.
  • As a source of ideas / reasoning for your own research (if properly referenced)
  • For editing and paraphrasing (check your institution's definition of plagiarism and recommended paraphrase).
This we believe is a better way of understanding a problem and makes use of the efficiency of time of the student.

NEW ASSIGNMENT HELP?

Order New Solution. Quick Turnaround

Click on the button below in order to Order for a New, Original and High-Quality Essay Solutions. New orders are original solutions and precise to your writing instruction requirements. Place a New Order using the button below.

WE GUARANTEE, THAT YOUR PAPER WILL BE WRITTEN FROM SCRATCH AND WITHIN YOUR SET DEADLINE.

Order Now