""" ------------------------------------------------- Project: Take Away Game School: Tauranga Boys' College Author: Kylan Driver Date: March 202 Python: 3.11.9 ------------------------------------------------- """ #imports: import random import time #Game variables for code to work: #Chip constant variable: MAX_CHIPS = 21 #Player score count variables: PlayerOneScore = 0 PlayerTwoScore = 0 #Variables to determine how many chips are left or taken: chipsLeft = 0 chipsTaken = 0 #Determining the names of the players and checking if it has numbers in it: while True: playerOneName = input("What is the name of the first player: ") if playerOneName.isalpha() == True: break else: print("That is not a nice name, change it rn buddy.") while True: playerTwoName = input("What is the name of the second player: ") if playerTwoName.isalpha() == True: break else: print("That is not a nice name, change it rn buddy.") #Telling the players to enter a number of rounds: rounds = int(input("How many rounds do u think u guys wanna play: ")) #Main loops for the game: while rounds > 0: chipsLeft = MAX_CHIPS #Telling the player how many chips there are left while the amount is greater than 0: while chipsLeft > 0: print("left chips:", chipsLeft) #first players turn: chipsTaken = int(input(playerOneName +" take sum chips 1-3: ")) if chipsTaken >= 1 and chipsTaken <= 3 and chipsTaken <= chipsLeft: chipsLeft = chipsLeft - chipsTaken if chipsLeft < 1: PlayerOneScore = PlayerOneScore + 1 if chipsTaken >=4: print("That is not valid, your turn will be skipped as penalty. Choose a different number between 1-3 next time.") print("left chips:", chipsLeft) #second players turn: if chipsLeft > 0: chipsTaken = int(input(playerTwoName +" take sum chips 1-3: ")) if chipsTaken >= 1 and chipsTaken <= 3 and chipsTaken <= chipsLeft: chipsLeft = chipsLeft - chipsTaken if chipsLeft < 1: PlayerTwoScore = PlayerTwoScore + 1 if chipsTaken >=4: print("That is not valid, your turn will be skipped as penalty. Choose a different number between 1-3 next time.") #making the code know how many rounds there are left to play: rounds = rounds - 1 #choosing which player won the game: print("Game Over!") print(playerOneName + " this is ur points ->", PlayerOneScore) print(playerTwoName + " this is ur points ->", PlayerTwoScore) if PlayerOneScore > PlayerTwoScore: print(playerOneName + " won since they had more points") else : print(playerTwoName + " won since they had more points")