""" ------------------------------------------------- Project: 21 chip game Standard: TE PUNGA - Programming Assessment School: Tauranga Boys' College Author: Ethan Carleton Date: March 2025 Python: 3.7.4 ------------------------------------------------- """ #max chips max_chips = 21 #player1 score player1_score = 0 #player2 score player2_score = 0 #chipsleft chipsleft = 0 #chipstaken chipstaken = 0 #how players take the chips take = 0 #asking for the players names player1 = input("Enter a Player 1's name: ") player2 = input("Enter a Player 2's name: ") #explaining how the games work and the goal print("Hello", player1, "and", player2, "in this game your goal is to get the chips exactly down to zero on your turn. You get to guess from 1 - 3 chips each turn.") #asking for a number of rounds rounds = int(input("Enter a number of rounds: ")) #displaying the players scores print( player1, "score : ", player1_score) print( player2, "score : ", player2_score) #rounds loop while rounds > 0: #this shows the total amount of chips chipsleft = max_chips #this lets the game keep going while there are still chips left while chipsleft > 0: #displaying how many chips are left print("chips left", chipsleft ) #asking how many chips player 1 will like to take take = int(input("Player 1 How many chips would you like to take? 1 - 3: ")) print() #subtracting the how many chips player 1 took from the total amount of chips chipsleft = chipsleft - take #if player 1 got the total amount of chips too 0 then it will say that player 1 has won this round if chipsleft < 1 : print() print(player1, "has won the round" ) player1_score +=1 #displaying the player scores print( player1, "score : ", player1_score) print( player2, "score : ", player2_score) break #displaying chips left print("chips left", chipsleft ) #asking player 2 how many chips they will like to take take = int(input("Player 2 How many chips would you like to take? 1 - 3: ")) print() #subtracting the how many chips player 2 took from the total amount of chips chipsleft = chipsleft - take #if player 2 got the total amount of chips too 0 then it will say that player 2 has won this round if chipsleft < 1 : print() print(player2, "has won the round" ) player2_score +=1 #displaying player scores print( player1, "score : ", player1_score) print( player2, "score : ", player2_score) #stops the code from continuing break #taking a round off the total amount of rounds rounds -=1 print() if rounds == 0 and chipsleft <1: if player1_score > player2_score: print(player1, "has won the game !") elif rounds == 0 and chipsleft <1: if player2_score > player1_score: print(player2, "has won the game !")