[SOLVED] PSP0101 Assignment 1-Battle of the Sexes (B.O.T.S)

30.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon Battle-of-the-Sexes-B.O.T.S-main-ud7fgr.zip (975.5 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
πŸ”’ Securely Powered by:
Secure Checkout
5/5 - (2 votes)

Battle of the Sexes (B.O.T.S)

Tony and Pepper is a married couple. Due to their heavy commitment at work, they have not been dating for quite some time. They decided to do something different for their next date. Unfortunately, they could not make up their mind. Tony was looking forward to watch Copa America’s final football match with Pepper, while Pepper wanted Tony to join her for the live concert of Super Junior boy band. Both the match and live concert were held on the same day, and both Tony and Pepper did not want to forgo their preferences.

Morgan, a 5-year-old programming genius and the daughter of Tony and Pepper, loves her parents very much. She figured that the best way to resolve her parents’ differences was to let them play a fair game, the winner of which gets to decide the plan for the date. Although Morgan could have used any existing board games for this purpose, she thought that it is more fun to design a new game and program it to run on a computer. She called her new game as β€œBattle of the Sexes”, or B.O.T.S in short.

Mission

You are to develop the game β€œBattle of the Sexes” using Python programming language based on Problem Description and Program Requirements below.

Deadline

Submit your Deliverables to MMLS by Monday, 30th September 2019 (on or before 11:59 pm). Grouping

To be done in a group of maximum 2 students. KWBAN

Starter Kit

You should find a folder named Starter Kit in the same folder as this document. This folder contains files that help you kick start your assignment. Here are the files in the folder:

1. psphelper.py
This Python source code contains some helpful functions that you can use in your program. Check out the documentation of each

function to know what they do. You do not have to modify this file at all. 2. Tutorial.py

This Python source code demonstrates how to use the functions in psphelper.py. Run it to see how the functions in psphelper.py are used.

3. game.exe_rename
This is actually an executable for the game. It is given for your reference. To run it, kindly rename it to game.exe, open command

prompt at the executable’s location, and type game.

KWBAN

Problem Description

Here are the general descriptions about the game to be developed for this assignment.

  1. (1) Β Battle of the Sexes is a two-player turn-based game in which players competes for the highest score by rolling dice to make certain

    combinations.

  2. (2) Β There are Five (5) dice to roll. Each die is a tetrahedron (i.e. a triangular pyramid with 4 faces) and therefore has Four (4) values only: 1,

    2, 3 and 4.

  3. (3) Β The game begins with each player having a total score of 0.
  4. (4) Β The game consists of 9 rounds. In each round, the players take turns to roll dice. Each player can roll the dice up to three (3) times,

    but they can choose to accept the dice and stop rolling before the third roll. After the first or second roll, the player can re-roll some or all

    dice.

  5. (5) Β There are 9 scoring categories with which the dice are matched. After the third roll or after the player accepts the dice, the player has to

    choose which scoring category the dice is to be used. The player can only use a scoring category once.

  6. (6) Β Each scoring category has its own matching condition and scoring rule. Some of the matching conditions accept any dice combination, while others are specific to certain dice combinations. Some of the scoring rules are fixed scores, while others depend on the dice’s

    values. The table below illustrates all scoring categories in B.O.T.S.

Category

Matching Condition

Scoring Rule

Example

Ones (1S)

Any combination

Sum of dice with number 1

Score = 3

Twos (2S)

Any combination

Sum of dice with number 2

Score = 0

Threes (3S)

Any combination

Sum of dice with number 3

Score = 6

Fours (4S)

Any combination

Sum of dice with number 4

Score = 4

KWBAN

Trio

At least three dice the same

Sum of ALL dice

Score = 8
Score = 0 (do not match)

Quartet

At least four dice the same

Sum of ALL dice

Score = 0 (do not match) Score = 14

Doremi

Four sequential dice (1-2-3-4)

20

Score = 0 (do not match) Score = 20

Band

Three of one number and two of the other

30

Score = 30
Score = 0 (do not match)

Orchestra

All five dice the same

40

Score = 40

(7) The scores obtained from the chosen scoring category will be accumulated into the player’s total score.
(8) After completing all rounds, the game ends and both players’ total scores are compared. The player who has the highest score wins.

KWBAN

Program Requirements

Here are the requirements that your program must satisfy to get FULL marks. You should read this while running game.exe for better understanding.

(A) Interface and Appearance

1) FirstInterface
The First Interface is the user interface that is always displayed first at each player’s turn. It contains several parts: Game Title, Scoreboard, Player’s Total, Current Player, and Roll-Dice Prompt. The example below illustrates each part clearly.

Example:

(a) Game Title: The game title is centre-justified on a width of 80 characters.
(b) Scoreboard: This part shows the players’ scores for each scoring category that has been used. (c) Player’s Total: This part shows the total scores the player has accumulated.
(d) Roll Dice Prompt: This part instructs the current player to roll the dice to begin playing.

KWBAN

(B) Program Logic

(1) The game begins with Player 1 starts first. At the beginning of each turn, the command prompt screen is cleared before the First Interface is displayed, causing the First Interface to be displayed at the top of the screen.
[HINTS: Check out Tutorial.py for help on how to clear screen and display the Scoreboard.]

======================== Battle of the Sexes (B.O.T.S) ======================== Scoreboard +———-+—-+—-+—-+—-+——+———+——+——–+———–+
| | 1S | 2S | 3S | 4S | Trio | Quartet | Band | Doremi | Orchestra | +———-+—-+—-+—-+—-+——+———+——+——–+———–+ |Player1| | | | | | | | | | +———-+—-+—-+—-+—-+——+———+——+——–+———–+ |Player2| | | | | | | | | | +———-+—-+—-+—-+—-+——+———+——+——–+———–+

Player 1: 0
Player 2: 0
Player 1
========
Press ENTER to roll dice.

(2) The player is asked to press the Enter key for the first roll. After the Enter key is pressed, the game will show β€œRoll #1” to indicate that this is the first roll, and will show a list of 5 random integers, each indicating the value of each die. This integer list is referred to as dice combination. Following the dice combination is a table titled β€œCategory Scores”, which shows the scores the dice combination would contribute for each scoring category (refer to Problem Description for how the scores are calculated).

======================== Battle of the Sexes (B.O.T.S) ======================== Scoreboard +———-+—-+—-+—-+—-+——+———+——+——–+———–+
| | 1S | 2S | 3S | 4S | Trio | Quartet | Band | Doremi | Orchestra | +———-+—-+—-+—-+—-+——+———+——+——–+———–+ |Player1| | | | | | | | | | +———-+—-+—-+—-+—-+——+———+——+——–+———–+ |Player2| | | | | | | | | | +———-+—-+—-+—-+—-+——+———+——+——–+———–+

Player 1: 0
Player 2: 0
Player 1
========
Press ENTER to roll dice.

KWBAN

Roll #1 : [1, 2, 3, 1, 2]

Category Scores +—-+—-+—-+—-+——+———+——+——–+———–+ | 1S | 2S | 3S | 4S | Trio | Quartet | Band | Doremi | Orchestra | +—-+—-+—-+—-+——+———+——+——–+———–+ |2|4|3|0| 0| 0| 0| 0| 0| +—-+—-+—-+—-+——+———+——+——–+———–+

(3) The Category Stores table is followed by Input Options, which shows the commands that the player can perform. The player can accept the dice combination, re-roll all 5 dice, or re-roll just the dice specified by a space-separated list of dice ordering number. An input prompt follows Input Options, waiting for the player to enter a command.

======================== Battle of the Sexes (B.O.T.S) ======================== Scoreboard +———-+—-+—-+—-+—-+——+———+——+——–+———–+
| | 1S | 2S | 3S | 4S | Trio | Quartet | Band | Doremi | Orchestra | +———-+—-+—-+—-+—-+——+———+——+——–+———–+ |Player1| | | | | | | | | | +———-+—-+—-+—-+—-+——+———+——+——–+———–+ |Player2| | | | | | | | | | +———-+—-+—-+—-+—-+——+———+——+——–+———–+

Player 1: 0
Player 2: 0
Player 1
========
Press ENTER to roll dice.
Roll #1 : [1, 2, 3, 1, 2]

Category Scores +—-+—-+—-+—-+——+———+——+——–+———–+ | 1S | 2S | 3S | 4S | Trio | Quartet | Band | Doremi | Orchestra | +—-+—-+—-+—-+——+———+——+——–+———–+ |2|4|3|0| 0| 0| 0| 0| 0| +—-+—-+—-+—-+——+———+——+——–+———–+

Input Options:
SAVE :- Accept these dice.
ROLL :- Re-roll ALL dice.
ROLL d1 … dn :- Re-roll specified dice only.

Input >

(4) To accept the dice combination, the player must type β€œSAVE” in any letter casing (i.e. inputs like β€œSAVE”, β€œsave”, β€œsAvE” are valid, as long as the word β€œsave” is typed). The game will proceed to the selection of scoring category for the accepted dice combination as

KWBAN

detailed in (8).

======================== Battle of the Sexes (B.O.T.S) ======================== Scoreboard +———-+—-+—-+—-+—-+——+———+——+——–+———–+
| | 1S | 2S | 3S | 4S | Trio | Quartet | Band | Doremi | Orchestra | +———-+—-+—-+—-+—-+——+———+——+——–+———–+ |Player1| | | | | | | | | | +———-+—-+—-+—-+—-+——+———+——+——–+———–+ |Player2| | | | | | | | | | +———-+—-+—-+—-+—-+——+———+——+——–+———–+

Player 1: 0
Player 2: 0
Player 1
========
Press ENTER to roll dice.
Roll #1 : [1, 2, 3, 1, 2]

Category Scores +—-+—-+—-+—-+——+———+——+——–+———–+ | 1S | 2S | 3S | 4S | Trio | Quartet | Band | Doremi | Orchestra | +—-+—-+—-+—-+——+———+——+——–+———–+ |2|4|3|0| 0| 0| 0| 0| 0| +—-+—-+—-+—-+——+———+——+——–+———–+

Input Options:
SAVE :- Accept these dice.
ROLL :- Re-roll ALL dice.
ROLL d1 … dn :- Re-roll specified dice only.

Input > sAVE
Enter your desired category:

(5) To re-roll all dice, the player must type β€œROLL” in any letter casing (i.e. inputs like β€œROLL”, β€œroll”, β€œRolL” are valid, as long as the word β€œroll” is typed). The game will roll the dice again, showing the dice combination and its corresponding Category Scores similar to Program Logic (2) and (3). However, this time the roll number is either 2 (the second roll), or 3 (the third roll).

======================== Battle of the Sexes (B.O.T.S) ======================== Scoreboard +———-+—-+—-+—-+—-+——+———+——+——–+———–+
| | 1S | 2S | 3S | 4S | Trio | Quartet | Band | Doremi | Orchestra | +———-+—-+—-+—-+—-+——+———+——+——–+———–+ |Player1| | | | | | | | | | +———-+—-+—-+—-+—-+——+———+——+——–+———–+ |Player2| | | | | | | | | | +———-+—-+—-+—-+—-+——+———+——+——–+———–+

KWBAN

Player 1: 0
Player 2: 0
Player 1
========
Press ENTER to roll dice.
Roll #1 : [1, 2, 3, 1, 2]

Category Scores +—-+—-+—-+—-+——+———+——+——–+———–+ | 1S | 2S | 3S | 4S | Trio | Quartet | Band | Doremi | Orchestra | +—-+—-+—-+—-+——+———+——+——–+———–+ |2|4|3|0| 0| 0| 0| 0| 0| +—-+—-+—-+—-+——+———+——+——–+———–+

Input Options:
  SAVE
  ROLL
  ROLL d1 ... dn
Input > Roll
Roll #2 : [3, 1,

:- Accept these dice.
:- Re-roll ALL dice.
:- Re-roll specified dice only.

3, 1, 1]

Category Scores +—-+—-+—-+—-+——+———+——+——–+———–+ | 1S | 2S | 3S | 4S | Trio | Quartet | Band | Doremi | Orchestra | +—-+—-+—-+—-+——+———+——+——–+———–+ |3|0|6|0|9| 0|25| 0| 0| +—-+—-+—-+—-+——+———+——+——–+———–+

Input Options:
SAVE :- Accept these dice.
ROLL :- Re-roll ALL dice.
ROLL d1 … dn :- Re-roll specified dice only.

Input >

(6) To re-roll some dice, the player must type β€œROLL … ”, where to are space-separated list of positive integers corresponding to which die or dice to roll (e.g. β€œROLL 1 3” means roll the 1st and the 3rd die). Similar to (5), the word β€œROLL” is case- insensitive. However, the order of to need not be sorted (i.e. β€œROLL 1 3” should work the same as β€œROLL 3 1”), and duplicates are allowed in the integer list (e.g. β€œROLL 1 3 1 1 3” should work the same as β€œROLL 1 3”). The output upon executing this command is similar to (5).

======================== Battle of the Sexes (B.O.T.S) ======================== Scoreboard +———-+—-+—-+—-+—-+——+———+——+——–+———–+

KWBAN

| | 1S | 2S | 3S | 4S | Trio | Quartet | Band | Doremi | Orchestra | +———-+—-+—-+—-+—-+——+———+——+——–+———–+ |Player1| | | | | | | | | | +———-+—-+—-+—-+—-+——+———+——+——–+———–+ |Player2| | | | | | | | | | +———-+—-+—-+—-+—-+——+———+——+——–+———–+

Player 1: 0
Player 2: 0
Player 1
========
Press ENTER to roll dice.
Roll #1 : [4, 4, 2, 4, 4]

Category Scores +—-+—-+—-+—-+——+———+——+——–+———–+ | 1S | 2S | 3S | 4S | Trio | Quartet | Band | Doremi | Orchestra | +—-+—-+—-+—-+——+———+——+——–+———–+ | 0| 2| 0|16| 18| 18| 0| 0| 0| +—-+—-+—-+—-+——+———+——+——–+———–+

Input Options:
  SAVE
  ROLL
  ROLL d1 ... dn
Input > roll 2 1
Roll #2 : [1, 2,

:- Accept these dice.
:- Re-roll ALL dice.
:- Re-roll specified dice only.

5 4 1
2, 3, 2]

Category Scores +—-+—-+—-+—-+——+———+——+——–+———–+ | 1S | 2S | 3S | 4S | Trio | Quartet | Band | Doremi | Orchestra | +—-+—-+—-+—-+——+———+——+——–+———–+ |1|6|3|0|10| 0|0| 0| 0| +—-+—-+—-+—-+——+———+——+——–+———–+

Input Options:
SAVE :- Accept these dice.
ROLL :- Re-roll ALL dice.
ROLL d1 … dn :- Re-roll specified dice only.

Input >

(7) Apart from the SAVE and ROLL commands, the game also secretly supports the cheat command to overwrite the dice to a desired combination. The cheat command syntax is β€œCHEAT … ”. Here, to is a space-separated list of 5 positive integers that each represents the face value of a die (this is unlike the command for re-rolling some dice). The word β€œCHEAT” is case-insensitive, but there must be exactly 5 positive integers for the integer list. Since each die has only 4 values, the condition must be true.

KWBAN

The cheat command can only be used once per turn, so no other commands are allowed after executing the cheat command. Upon executing the cheat command, the game will show the Category Scores corresponding to the entered dice, and proceed to the selection of scoring category (see (8)).

======================== Battle of the Sexes (B.O.T.S) ======================== Scoreboard +———-+—-+—-+—-+—-+——+———+——+——–+———–+
| | 1S | 2S | 3S | 4S | Trio | Quartet | Band | Doremi | Orchestra | +———-+—-+—-+—-+—-+——+———+——+——–+———–+ |Player1| |8| | | | | | | | +———-+—-+—-+—-+—-+——+———+——+——–+———–+ |Player2| | | | | | | | 20| | +———-+—-+—-+—-+—-+——+———+——+——–+———–+

Player 1: 8
Player 2: 20
Player 1
========
Press ENTER to roll dice.
Roll #1 : [1, 3, 2, 2, 2]

Category Scores +—-+—-+—-+—-+——+———+——+——–+———–+ | 1S | 2S | 3S | 4S | Trio | Quartet | Band | Doremi | Orchestra | +—-+—-+—-+—-+——+———+——+——–+———–+ |1|6|3|0|10|0|0|0| 0| +—-+—-+—-+—-+——+———+——+——–+———–+

Input Options:
SAVE :- Accept these dice.
ROLL :- Re-roll ALL dice.
ROLL d1 … dn :- Re-roll specified dice only.

Input > cheat 1 1 1 1 0
ERROR: Invalid input.
Input > cheat 1 1 -1 1 1
ERROR: Invalid input.
Input > cheat 1 1 1 1
ERROR: Invalid input.
Input > cheat 1 a 1 1 1
ERROR: Invalid input.
Input > cheat 1 1 1 1 1
Category Scores +—-+—-+—-+—-+——+———+——+——–+———–+ | 1S | 2S | 3S | 4S | Trio | Quartet | Band | Doremi | Orchestra | +—-+—-+—-+—-+——+———+——+——–+———–+ |5|0|0|0|5| 5|0| 0| 40|

KWBAN

+—-+—-+—-+—-+——+———+——+——–+———–+ Enter your desired category:

(8) The player has up to three (3) rolls per turn. Once the player has finalized the dice (i.e. has accepted the dice, rolled three times, or used the cheat command), the player is asked to enter the name of his desired scoring category for his finalized dice (as seen in the Category Scores table). If the entered scoring category has previously used, the game will report an error and ask the player to enter again.

Once the scoring category is entered, the player’s turn ends. His scoreboard will be updated with the new score obtained from the chosen scoring category, and his total score will be updated accordingly. After this, the next player’s turn begins.

======================== Battle of the Sexes (B.O.T.S) ======================== Scoreboard +———-+—-+—-+—-+—-+——+———+——+——–+———–+
| | 1S | 2S | 3S | 4S | Trio | Quartet | Band | Doremi | Orchestra | +———-+—-+—-+—-+—-+——+———+——+——–+———–+ |Player1| |8| | | | | | | 40| +———-+—-+—-+—-+—-+——+———+——+——–+———–+ |Player2| | | | | | | | 20| | +———-+—-+—-+—-+—-+——+———+——+——–+———–+

Player 1: 48
Player 2: 20
Player 2
========
Press ENTER to roll dice.
Roll #1 : [1, 4, 2, 4, 4]

Category Scores +—-+—-+—-+—-+——+———+——+——–+———–+ | 1S | 2S | 3S | 4S | Trio | Quartet | Band | Doremi | Orchestra | +—-+—-+—-+—-+——+———+——+——–+———–+ |1|2|0|12|15| 0|0| 0| 0| +—-+—-+—-+—-+——+———+——+——–+———–+

Input Options:
SAVE :- Accept these dice.
ROLL :- Re-roll ALL dice.
ROLL d1 … dn :- Re-roll specified dice only.

Input > save

Enter your desired category: doremi ERROR: Category ‘doremi’ has been used. Enter your desired category: tri
ERROR: Category ‘ban’ does not exist. Enter your desired category: trio

======================== Battle of the Sexes (B.O.T.S) ======================== Scoreboard +———-+—-+—-+—-+—-+——+———+——+——–+———–+
| | 1S | 2S | 3S | 4S | Trio | Quartet | Band | Doremi | Orchestra | +———-+—-+—-+—-+—-+——+———+——+——–+———–+ |Player1| |8| | | | | | | 40| +———-+—-+—-+—-+—-+——+———+——+——–+———–+ |Player2| | | | | 15| | | 20| | +———-+—-+—-+—-+—-+——+———+——+——–+———–+

Player 1: 48
Player 2: 35
Player 1
========
Press ENTER to roll dice.

KWBAN

(9) The game continues to run for 9 rounds, with the screen of the command prompt cleared upon turn exchanges. After 9 rounds, the game ends, showing the Game Title, Scoreboard, and Players’ Total. The winner is determined by the player with the highest total score. If both players have the same score, it is considered a tie.

======================== Battle of the Sexes (B.O.T.S) ======================== Scoreboard +———-+—-+—-+—-+—-+——+———+——+——–+———–+
| | 1S | 2S | 3S | 4S | Trio | Quartet | Band | Doremi | Orchestra | +———-+—-+—-+—-+—-+——+———+——+——–+———–+ |Player1|2|6|6|4| 0| 0|25| 0| 0| +———-+—-+—-+—-+—-+——+———+——+——–+———–+ |Player2|0|6|3|4|15| 0| 0| 0| 0| +———-+—-+—-+—-+—-+——+———+——+——–+———–+

Player 1: 43
Player 2: 28
Player 1 wins!

======================== Battle of the Sexes (B.O.T.S) ======================== Scoreboard +———-+—-+—-+—-+—-+——+———+——+——–+———–+
| | 1S | 2S | 3S | 4S | Trio | Quartet | Band | Doremi | Orchestra | +———-+—-+—-+—-+—-+——+———+——+——–+———–+

| Player 1 | 0 | 6 | 3 | 4 | 15 | 0 | 25 | 0 | 0 | +———-+—-+—-+—-+—-+——+———+——+——–+———–+ | Player 2 | 0 | 6 | 3 | 4 | 15 | 0 | 25 | 0 | 0 | +———-+—-+—-+—-+—-+——+———+——+——–+———–+

Player 1: 28
Player 2: 28

It’s a tie.

KWBAN

Source Code Requirements

Your source code must be able to be interpreted without errors with Python 3.7 Interpreter or later running on a Windows machine (Windows 7 or later). If your source code cannot be interpreted, you get ZERO for your whole assignment. Once your code successfully runs, the following requirements are evaluated.

(A) Documentation and Comments

Best if your code is self-explanatory, that is, your identifiers are very well-named and your readers know their purposes without extra explanation. In situations where this is hard to achieve, you should add short comments to explain the purpose of declaring a variable or a block of code.

Deliverables

You are to submit the following for this assignment:

1. ONE (1) Python source code for the program with appropriate comments inside the code. Insert your information (file name, members’ names, IDs, emails, and phone numbers) at the beginning of the file as follows:

#################################################### # Program: YOUR_FILENAME.py
# Course: PSP0101 PROBLEM SOLVING AND PROGRAM DESIGN # Class: A01

# Year: 2018/19 Trimester 3
# Names: MEMBER_NAME_1 | MEMBER_NAME_2
# IDs: MEMBER_ID_1 | MEMBER_ID_2
# Emails: MEMBER_EMAIL_1 | MEMBER_EMAIL_2
# Phones: MEMBER_PHONE_1 | MEMBER_PHONE_2 ####################################################

KWBAN

Submission Instructions

Submit the SOFTCOPY of your deliverables to MMLS. Detail instructions on how to upload your deliverable will be announced in the MMLS.

To prepare your submission, you must strictly follow the instructions below. Failure to follow any of the instructions below will result in mark deduction:

  1. Name your .py file following the following format:

    GIVENNAME1-GIVENNAME2
    (a) GIVENNAME# – The given name of member # as seen in CamSys. Replace spaces with underscores ( _ ) as NO SPACE IS

    ALLOWED. You may use short names if your name is too long (e.g. Mohd for Mohammad, etc.). Example:

         JUSTIN_BIEBER-SELENA_GOMEZ.py
    
  2. Put your Deliverables in a folder, and name the folder similarly as your Python filename (without the .py extension of course).
  3. Compress your folder as a ZIP archive (We recommend 7-Zip software for this task, but you can use any software that you know). At this point, your ZIP archive should contain a folder that contains your Deliverables.
  4. Double check your ZIP file before submitting to ensure that you have submitted the correct code and the code can be interpreted and run on Windows machine.

KWBAN

Presentation

You are required to present your program after submission by demonstrating how your program works. There will be a Q & A session after your presentation.

The date of the presentation will be announced around the submission deadline.

The information about how the presentation will be conducted will be announced in MMLS around the submission date. Kindly check the MMLS announcement for the latest information.

1 file Β· 975.5 KB

  • Battle-of-the-Sexes-B.O.T.S-main-ud7fgr.zip 975.5 KB