# End of UNIT 2: Programming Project - GAME OF PIG # # Purpose: to create a two player text based game. # 1. Complete the code -alone- using the template below. # 2. Do not 're-write' the project,...

1 answer below »
Please complete my assignment for Computer Science. I am unable to properly program it according to the given template.


# End of UNIT 2: Programming Project - GAME OF PIG # # Purpose: to create a two player text based game. # 1. Complete the code -alone- using the template below. # 2. Do not 're-write' the project, make use of it. # 3. Rules of the Game: # 4. Human vs. Computer - Human player against the computer # 5. Game ends when one player reaches 100 banked points # 6. During a turn, a player accumulates a score # A turn ends when (a) a player banks the score adding # the current score to their banked score or (b) when # the player rolls a one (1) on the die - loosing all # points accumulated that round (the banked score is safe) # 7. Note: A turn is a series of dice rolls # 8. At the end of the game, ask to play again. # 9. Follow the Major Programming Rubric - Keep a Journal! # 0. REMOVE TEMPLATE INSTRUCTIONS - REPLACE WITH YOUR COMMENTS # # Author: YOUR NAME HERE # # Date: DATE SUBMITTED HERE # # Setup the initial environment import random # a dictionary of dice - a data structure to make the game pretty # - in Thonny increase font size under view to see them properly dice = { 1 : "⚀", 2 : "⚁", 3 : "⚂", 4 : "⚃", 5 : "⚄", 6 : "⚅" } die = random.randint(1,6) # to generate a random die from 1 to 6 play = True # Main Game Loop Flag - assume true answer = "NA" # user input stored to play game humanBank = 0 # memory requirements for two players humanScore = 0 computerBank = 0 computerScore = 0 # Welcome Screen - human instructions print("""\ ___ __ ___ _ / __|__ _ _ __ ___ ___ / _| | _ (_)__ _ | (_ / _` | ' \/ -_) / _ \ _| | _/ / _` | \___\__,_|_|_|_\___| \___/_| |_| |_\__, | |___/ """) # Print the game instructions here # GAME LOOP while play == True: # HUMAN PLAYER GOES FIRST - PLACE CODE HERE humanScore = 0 # initial value at the start of each turn die = 0 # impossible die value to enter player turn loop # a. you will need a turn loop for the human player answer = input("(r)oll or (h)old? ") while answer.lower() == 'r' and die != 1: # print the roll of the die die = random.randint(1,6) print("you rolled {0}".format(dice.get(die))) # b. update humanScore here # c. AFTER LOOP: update humanBank # d. Output current state of humanScore and HumanBank to human player # Check game state . . Did the human win? # COMPUTER PLAYER CODE HERE # a. Inteligent turn loop for computer .. think about it .. code it. # The computer needs to 'chase' the human if behind in points. # The computer needs to play conservatively if it is winning # The computer needs to 'risk' more if close to the goal of 100 points # Check Game State ... if # GAME OVER - Report who won print("""\ ___ ___ / __|__ _ _ __ ___ / _ \__ _____ _ _ | (_ / _` | ' \/ -_) | (_) \ V / -_) '_| \___\__,_|_|_|_\___| \___/ \_/\___|_| """) # Ask to Play Again # END PROGRAM - Inform Player print("Thank's for playing!")
Answered 214 days AfterJul 03, 2021

Answer To: # End of UNIT 2: Programming Project - GAME OF PIG # # Purpose: to create a two player text based...

Neha answered on Feb 02 2022
125 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here