""" ------------------------------------------------- Project: Take-Away Game Standard: 91883 (AS1.7) v.1 School: Tauranga Boys' College Author: sean sajota Date: THE DATE YOU COMPLETED THE CODE Python: 3.5 ------------------------------------------------- This game is the Take-Away game. To play this game, you will need 2 players. The concept of the game is: Each player takes chips from the pile, and to win, you need to earn more chips than the other player. If both players have the same amount of chips at the end, it’s a tie. ------------------------------------------------- """ # Constants MAX_CHIPS = 21 # The amount of chips they will start with # Initialize scores player1Score = 0# player 1 scores player2Score = 0#player 2 scores # Get player names and rounds from the user player1 = input("PlayerOne, please enter your name: ")#player one putting their name in so they can have a name in the game player2 = input("PlayerTwo, please enter your name: ")#player2 putting their name in so the game would be able to call them rounds = int(input("Please enter how many rounds you want to play XD: "))#THE AMOUNT OF ROUNDS THEY WANNA PLAY AHAH # Game loop for multiple rounds while rounds > 0: chipsLeft = MAX_CHIPS # Reset the number of chips at the start of each round print(f"\nRound starts! {player1} and {player2}, THIS IS THE AMOUNT OF CHIPS {chipsLeft} .\n")# this pop ups when the player2 and player 1 wants to play # Start of the round, continue until the chips are gone while chipsLeft > 0: # Player 1's turn player1_chips = 0 while player1_chips != 1 and player1_chips != 2 and player1_chips != 3: player1_chips = int(input(f"{player1}, how many chips would you like to take (1-3): "))#player taking the othersides chips if player1_chips != 1 and player1_chips != 2 and player1_chips != 3: print("Bruh, you can only take 1, 2, or 3 chips!") # when player takes more than 3 chips chipsLeft -= player1_chips # the chips taken from player one decreases print(f"{player1} takes {player1_chips} chips. {chipsLeft} chips remaining.\n")#the amount of chips player1 has if chipsLeft <= 0: player1Score += 1 # Player 1 wins the round print(f"{player1} wins this round!\n")#player1 winning this round break # STOPS THE GAME LOOP # Player 2's turn player2_chips = 0#players 2 amount of chips while player2_chips != 1 and player2_chips != 2 and player2_chips != 3: player2_chips = int(input(f"{player2}, how many chips would you like to take (1-3): "))#player 2 taking chips if player2_chips != 1 and player2_chips != 2 and player2_chips != 3: print("Bruh, you can only take 1, 2, or 3 chips!") #if the player takes more than 3 chipsLeft -= player2_chips # minus the player 2 takes print(f"{player2} takes {player2_chips} chips. {chipsLeft} chips remaining.\n")# when player 2 takes chips from player 1 and shows how many chips if chipsLeft <= 0: player2Score += 1 # when player 2 wins print(f"{player2} wins this round!\n")#player 2 wins break # stop the game loop rounds -= 1 # the round decreases # Display final score and winner print("\nGame over!") # the game is over or done if player1Score > player2Score:# if player 1 wins the round this will work print(f"{player1} wins the game with {player1Score} points!")#when player 1 wins the game this will pop up elif player2Score > player1Score:# else if player2 wins this round print(f"{player2} wins the game with {player2Score} points!")# this will pop up if player2 wins else:# decides what to do if the condition is false print("It's a tie!")# if both player has the same amount of chips