""" ------------------------------------------------- Project: Take-Away Game Standard: 91883 (AS1.7) v.1 School: Tauranga Boys' College Author: YOUR FULL NAME Date: THE DATE YOU COMPLETED THE CODE Python: 3.5 ------------------------------------------------- This game is called the Take-Away Game. You need two in order to play this game. You will get 21 Chips in each round. You will get to select how many rounds that you need to play. Player 1 will get the chance to start the game. The round will end after the chips are finished. Good Luck ------------------------------------------------- """ MAX_CHIPS = 21 # The total number of chips at the start of each round # Initialize player scores PlayerOneScore = 0 PlayerTwoScore = 0 chipsleft = 0 chipsTaken = 0 # Get player names print("What are your names?") player1 = input("Player 1: ") player2 = input("Player 2: ") # Ask how many rounds they want to play rounds = int(input("How many rounds are you going to play: ")) # Start the game loop while rounds > 0: chipsleft = MAX_CHIPS while chipsleft > 0: # Continue playing until no chips are left print("Chips left:", chipsleft) # Player One's turn while True: chipsTaken = int(input(player1 + ", how many chips would you like to take? (1-3): ")) if 1 <= chipsTaken <= 3 and chipsTaken <= chipsleft: break else: print("You can only input from 1-3 chips.") chipsleft -= chipsTaken # Reduce the chip count by the chosen amount print("Chips left after", player1, "turn:", chipsleft) if chipsleft < 1: # Check if Player One took the last chip PlayerOneScore += 1 # Increase Player One's score print(player1, "wins this round!") break # Exit the round print("Chips left:", chipsleft) # Show updated chip count # Player Two's turn while True: chipsTaken = int(input(player2 + ", how many chips would you like to take? (1-3): ")) if 1 <= chipsTaken <= 3 and chipsTaken <= chipsleft: break else: print("You can only input from 1-3 chips.") chipsleft -= chipsTaken # Reduce the chip count by the chosen amount print("Chips left after", player2, "turn:", chipsleft) if chipsleft < 1: # Check if Player Two took the last chip PlayerTwoScore += 1 # Increase Player Two's score print(player2, "wins this round!") break # Exit the round rounds -= 1 # Reduce the number of remaining rounds # Display final scores and determine the overall winner print("Game Over!") print("Final Scores:") print(player1, "-", PlayerOneScore, "|", player2, "-", PlayerTwoScore) # Determine the overall winner if PlayerOneScore > PlayerTwoScore: print(player1, "wins the game!") elif PlayerTwoScore > PlayerOneScore: print(player2, "wins the game!") else: # If both players have the same number of wins, it's a tie print("It's a tie! Great match!")