#------------------------------------------------- #Project: Pick Up Game #Standard: 91883 (AS1.7) v.1 #School: Tauranga Boys' College #Author: Philjohn Ezekiel Mindanao #Date: 14/03/2025 #Python: 3.5 #------------------------------------------------- #This program plays a pick up game. #The players got to choose how many rounds do they wish to play. #The two players are going to pick a chips between 1 and 3 each turn. #The max chips is 21. #The last player that picks the last chip will win the game. #------------------------------------------------- #Import Libraries import time #This can be used for delays in case if needed #Greetings to the players at the beginning of the game print("Hello, Welcome to Pick Up Game!") time.sleep(1) print("Mechanics of the game:") #How does the game work time.sleep(1) print("The players got to choose how many rounds do they wish to play.") time.sleep(1) print("The two players are going to pick a chips between 1 and 3 each turn.") time.sleep(1) print("The max chips is 21.") time.sleep(1) print("The last player that picks the last chip will win the game.") time.sleep(1) #Inputs while True: #Loop until valid input is entered #Getting player 1's valid name player_1 = input("State your name player 1:") #Ask the player to put a proper name if player_1.isalpha() == True: break #Exit loop if the input is valid else: print("Please enter a relevant name!") #This will pop up if the player put an invalid name like numbers, etc. while True: #Loop until valid input is entered #Getting player 2's valid name player_2 = input("State your name player 2:") #Ask the player to put a proper name if player_2.isalpha() == True: break #Exit loop if the input is valid else: print("Please enter a relevant name!") #This will pop up if the player put an invalid name like numbers, etc. rounds_to_play = int(input("How many rounds do you wish to play?")) #Ask the player on how many rounds to play chips_taken = 0 #How many chips does the each player will take each turn #Game Variables rounds_played = 0 #How many rounds does the players have done player = 0 #How many players will play the game chips_left = 0 #How many chips are left #Initialise Players Scores player_1_score = 0 #Player One Score player_2_score = 0 #Player Two Score #Constants(It's a value that remain unchanged throughout the game) max_chips = 21 #The starting number of chips #Start of Round Loops while rounds_to_play > 0: chips_left = max_chips #Resets the chips left at the start of each round while chips_left > 0: #Continue the round until there are no chips left #Player 1's turn to pick on how many chips he/she will take print(f"Chips left: {chips_left}") while True: #Loop until valid input is entered player1Chips = int(input(f"{player_1}, How many chips do you wish to take between 1 & 3? ")) #Ask the player on how many chips he/she will take between 1 & 3 if 1 <= player1Chips <= 3 and player1Chips <= chips_left: break #Exit loop if the input is valid else: print(f"Please pick only between 1 and 3 chips.") #This will pop up if the player choose a negative number or greater than 3 chips_left -= player1Chips #Update chips left after Player One's turn if chips_left <= 0: #Check if Player One won the round player_1_score += 1 print(f"{player_1} Wins This Round!") #Player One Wins This Round break #End of the round #Player 2's turn to pick on how many chips he/she will take print(f"Chips left: {chips_left}") while True: #Loop until valid input is entered player2Chips = int(input(f"{player_2}, How many chips do you wish to take between 1 & 3? ")) #Ask the player on how many chips he/she will take between 1 & 3 if 1 <= player2Chips <= 3 and player2Chips <= chips_left: break #Exit loop if the input is valid else: print(f"Please pick only between 1 and 3 chips.") #This will pop up if the player choose a negative number or greater than 3 chips_left -= player2Chips #Update chips left after Player Two's turn if chips_left <= 0: #Check if Player Two won the round player_2_score += 1 print(f"{player_2} Wins This Round!") #Player Two Wins This Round break #End of the round rounds_to_play -= 1 #Advance to the next round #After all the rounds, check the player who won the game if player_1_score > player_2_score: print(f"{player_1} Wins the game!") #Player One wins the game elif player_2_score > player_1_score: print(f"{player_2} Wins the game!") #Player Two wins the game else: print("It's a draw!") #Player One and Two have the same score #Greetings to the players at the end of the game time.sleep(1) print("Thanks for playing pick up game!") time.sleep(1)