"""" --------------------------------" project: pick up game Standard: TE PUNGA - programming assessment School: Tauranga Boys' College Author: Eli blandford Date: """ import random #this is asking for both players name so I can use it in the code while True: player_1 = input("what is your name, player 1? ") if player_1.isalpha()==True: print("thank you") break else: print("please use letters") while True: player_2= input("what is your name player 2? ") if player_2.isalpha()==True: print("thank you " +player_1 +" and " + player_2 + " the game can now begin") break else: print("player 2 please use letters") #this is asking for how many games you want to play or you could choose a random amount while True: rounds=input("do you want to choose your rounds or just a random amount? please pick: choose or random ") if rounds.isalpha()==False: print("please words not numbers") else: if rounds== "choose" or rounds == "Choose": try: round_number= int(input("pick between 1 round and 5 rounds ")) if round_number <1 or round_number > 5: print("please choose a number between 1 and 5 ") else: print("you will be playing {} rounds".format(round_number)) break except: print("please a NUMBER between 1 and 5 not a letter") break elif rounds == "random" or rounds == "Random": round_number=random.randint(1,5) print("you will be playing {} rounds".format(round_number)) break else: print("please pick choose or random") max_chips=21 Player_One_score = 0 Player_Two_Score = 0 chipsLeft = 0 chips_taken = 0 player = 0 start_round_number = round_number play_again="y" #this the actual game and making sure the players can actually play the game and pick how many chips they want print("there are 21 chips left") while play_again== "y" or play_again=="Y": chipsLeft=max_chips player = random.randint(1,2) round_number = start_round_number while round_number > 0: # this is the player 1 picking up code I split the two players up so i can randomly select a player so its't player one that starts every time try: if player == 1: chips_taken = int(input(" {} how many chips will you take? ".format(player_1))) print("") if chips_taken < 1 or chips_taken > 3: print("please choose between 1 and 3") else: player = player + 1 chipsLeft = chipsLeft - chips_taken print("you have taken {} chips".format (chips_taken)) if chipsLeft < 0: chipsLeft = 0 print("there are {} left".format(chipsLeft)) if chipsLeft < 1: print("{} you took the last chips you win!".format(player_1)) chipsLeft=max_chips round_number = round_number - 1 Player_One_score += 1 print("the score is player 1, {} to player 2, {}".format(Player_One_score,Player_Two_Score)) # this is the player 2 code I split the two players up so i can randomly select a player so its't player one that starts every time elif player == 2: try: chips_taken = int(input(" {} how many chips will you take? ".format(player_2))) print("") if chips_taken < 1 or chips_taken > 3: print("please choose between 1 and 3") else: player = player - 1 chipsLeft = chipsLeft - chips_taken print("you have taken {} chips".format (chips_taken)) if chipsLeft < 0: chipsLeft = 0 print("there are {} left".format(chipsLeft)) if chipsLeft < 1: chipsLeft=max_chips round_number = round_number - 1 Player_Two_Score += 1 print ("{} you took the last chips you win!".format(player_2)) print("the score is {}, {} to {}, {}".format(player_1,Player_One_score,player_2,Player_Two_Score)) except: print("please use a number between 1 and 3 not letters") #this is to see if there is a winner if round_number < 1: print("the games are over! the scores are {} and {}".format(Player_One_score,Player_Two_Score)) #this is to see for the player 2 victory if Player_One_score < Player_Two_Score: print(" the winner is {}!".format(player_2)) play_again=input("would you like to play again? [y]es or [n]o? ") try: if play_again == "y": chipsLeft=max_chips player = random.randint(1,2) Player_One_score = 0 Player_Two_Score = 0 print("there are {} chips left".format(chipsLeft)) elif play_again == "n": break except: print("please choose y or n") #this is to seefor tie elif Player_One_score == Player_Two_Score: print("it is a draw! no one wins") play_again=input("would you like to play again? [y]es or [n]o? ") try: if play_again == "y": chipsLeft=max_chips player = random.randint(1,2) Player_One_score = 0 Player_Two_Score = 0 print("there are {} chips left".format(chipsLeft)) elif play_again == "n": break except: print("please choose y or n") #and this is to see for player 1 victory else: print(" the winner is {}!".format(player_1)) play_again=input("would you like to play again?" "[y]es or [n]o? ") try: if play_again == "y": chipsLeft=max_chips player = random.randint(1,2) Player_One_score = 0 Player_Two_Score = 0 print("there are {} chips left".format(chipsLeft)) elif play_again == "n": break except: print("please choose y or n") #this is for the chips taken is only numbers not letters except: print("please use a number between 1 and 3 not letters") print("thank you for playing my game!")