#------------------------------------------------------------------------------------------------------------------------------------------------------------- # Project: Pickupgame # Standard: TE PUNGA # School: Tauranga Boys College # Author: Shaun Zeldenrust # Date: 22/03/2024 # Python: 3.9.13 #------------------------------------------------------------------------------------------------------------------------------------------------------------- # This program plays a two player game. You and a friend take turns taking chips from a stack until there is nothing left in the stack, # Whoever takes the last remaining chips from the stack is rewarded with a point. You keep playing until the amount of rounds you selected has beeen reached. # Once all the rounds have been played, the program will sum up the final scores of both players to see who has the most points out of you and your friend. # Then the program will display who has won the game. Then the program ends #------------------------------------------------------------------------------------------------------------------------------------------------------------- # Import the time library so I can choose how my output is formated import time # Constant variable for max amount of chips for the stack MAXCHIPS=21 # Set variables round=1 Chips_Left=0 Chips_Taken=0 Player1_score=0 Player2_score=0 # User input for the two player names Player1=input("Player 1 enter your name: ") Player2=input("Player 2 enter your name: ") print() # Greeting and aim of the game print("Hello", Player1, "and", Player2) print("Welcome to Pick Up Game") print() time.sleep(1.5) print("Your goal is to be the last one to steal the last chips") # User inputs amount of rounds rounds=int(input("Select amount of rounds: ")) print() # Set rounds Loop while rounds > 0 : # Set Chips to "21" Chips_Left=MAXCHIPS print("Round", round) while Chips_Left > 0 : # Amount of chips left in the stack and menu for how much chips you can take per round print() print(Chips_Left,"Chips left") print() print("[1] Chip") if Chips_Left > 1 : print("[2] Chips") if Chips_Left > 2 : print("[3] Chips") print() time.sleep(1) # Player1s turn to take chips from the stack print(Player1) Chips_taken=int(input("How many Chips are you taking? ")) print() # Checking if the number of chips taken is a valid number if Chips_taken > 3 : print("Thats Not One Of The Choices!!!") Chips_Left=Chips_Left else : Chips_Left=Chips_Left-Chips_taken # If there are no more chips in the stack update player score and rounds if Chips_Left < 1: Player1_score+=1 rounds-=1 round+=1 break # Amount of chips left in the stack and menu for how much chips you can take per round print(Chips_Left,"Chips left") print() print("[1] Chip") if Chips_Left > 1 : print("[2] Chips") if Chips_Left > 2 : print("[3] Chips") print() time.sleep(1) # Player2s turn to take chips from the stack print(Player2) Chips_taken=int(input("How many Chips are you taking? ")) print() # Checking if the number of chips taken is a valid number if Chips_taken > 3 : print("Thats Not One Of The Choices!!!") Chips_Left=Chips_Left else : Chips_Left=Chips_Left-Chips_taken # If there are no more chips in the stack update player score and rounds if Chips_Left < 1: Player2_score+=1 rounds-=1 round+=1 break # Once the rounds loop is broken the final scores are displayed to determine a winner if rounds <1 : print("The final scores!") print() print(Player1, "you have a final score of", Player1_score) print(Player2, "you have a final score of", Player2_score) if Player1_score > Player2_score : print(Player1, "WINS!!!") else : print(Player2, "WINS!!!")