""" ------------------------------------------------- Project: Chip-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 ------------------------------------------------- """ import time import random # Constants MAX_CHIPS = 21 # Player names Player1Name = input("Enter Player One Name: ") Player2Name = input("Enter Player Two Name: ") # Number of rounds PlayerRounds = int(input("Enter Number of Rounds: ")) # Game loop for round_num in range(1, PlayerRounds + 1): print(f"\nRound {round_num}: Starting with {MAX_CHIPS} chips.") ChipsLeft = MAX_CHIPS # Reset chips at the start of each round current_player = Player1Name # Player 1 starts while ChipsLeft > 0: print(f"\nChips left: {ChipsLeft}") # Get player input try: ChipsTaken = int(input(f"{current_player}, how many chips do you want to take (1-5)? ")) # Validate input if ChipsTaken < 1 or ChipsTaken > 5 or ChipsTaken > ChipsLeft: print("Invalid move! You must take between 1 and 5 chips (or remaining chips). Try again.") continue # Ask again # Reduce chips ChipsLeft -= ChipsTaken # Check win condition if ChipsLeft == 0: print(f"\n{current_player} wins this round!") break # End round # Switch players current_player = Player2Name if current_player == Player1Name else Player1Name except ValueError: print("Invalid input! Please enter a number between 1 and 5.") print("\nGame Over! Thanks for playing!")