""" #------------------------------------------------- # Project: Take Away Game # School: Tauranga Boys' College # Author: Tyron Vassilatos # Date: March 2025 # Python: 3.7.4 #------------------------------------------------- """ #IMPORTS import random import time #VARIABLES FOR GAME #CONSTANT VARIABLE FOR CHIPS MAX_CHIPS = 21 #PLAYER SCORES player_one_score = 0 player_two_score = 0 #CHIPS LEFT/TAKEN chipsLeft = 0 chipsTaken = 0 #NAMES OF PLAYERS while True: name1 = str(input("What is Player One's Name? "))#MAKES PLAYERS OUTPUT THEIR NAMES if name1.isalpha() == True:#MAKES IT THAT IT CAN ONLY BE A NAME break else: print("That is not a great name, please put your real name.")#OUTPUTS THIS IF IT'S NOT A VALID NAME while True: name2 = str(input("What is Player Two's Name? ")) if name2.isalpha() == True: break else: print("That is not cool, please don't do that. Enter a good name. ") #WELCOMING PLAYERS print("Hello", name1, "and", name2) print("The rules that are applied to this game are as followed: Each player will take turns" " taking chips from the middle, the aim of the game is to be the person to take the last chip.") time.sleep(4) #NUMBER OF ROUNDS THAT THE PLAYERS WANT TO PLAY while True: try: number_of_rounds = int(input("How many rounds do you want to play 1-5:")) if number_of_rounds < 1 or number_of_rounds > 5: print("Please pick a number between 1-5") else: break except: print("You didn't put a number, really, please don't be like this") #SETTING UP GAME MAX_CHIPS = 21 roundsplayed = 0 score1 = 0 score2= 0 #MAIN GAME LOOP while number_of_rounds > 0: chipsLeft = MAX_CHIPS while chipsLeft > 0: print("Chips Left:" , chipsLeft) print("How many chips would you like to take,", name1, "1-3...") #PLAYER ONE TURN AND CHANGES THE PLAYER SCORE ONCE DONE if chipsLeft > 0: chipsTaken = int(input("Chips: ")) if chipsTaken >= 1 and chipsTaken <= 3 and chipsTaken <= chipsLeft: chipsLeft = chipsLeft - chipsTaken if chipsLeft > 1: player_one_score = player_one_score + 1 if chipsTaken >= 4: print("You have taken too many chips, your turn will be skipped due to this fault.") print("Chips Left:",chipsLeft) print("How many chips do you want to take,", name2, "1-3...") #PLAYER TWO TURN if chipsLeft > 0: chipsTaken = int(input("Chips: "))#INPUT FOR CHIPS if chipsTaken >= 1 and chipsTaken <= 3 and chipsTaken <= chipsLeft: chipsLeft = chipsLeft - chipsTaken #TAKES THE AMOUNT OF CHIPSTAKEN FROM CHIPSLEFT if chipsLeft > 1: player_two_score = player_two_score + 1 #INCREASES THE PLAYER SCORE BY ONE if chipsTaken >= 4: print("You have taken too many chips, your turn will be skipped due to this fault.") number_of_rounds = number_of_rounds - 1 #DETERMINES WHO ONE AND THE FINAL SCORES SCORES OF THE GAME print("Rounds and the game are over!!") print(name1, ",these are your final scores:", player_one_score)#PRINTS PLAYER ONE SCORE print(name2, ",these are your final scores:", player_two_score)#PRINTS PLAYER TWO SCORE if player_one_score > player_two_score: print(name1, "has won the game!")#PRINTS IF PLAYER ONE HAS WON else: print(name2, "has won the game!")#PRINTS IF PLAYER TWO HAS WON