#------------------------------------------------- # Project: Take-Away Game # Standard: 91883 (AS1.7) v.1 # School: Tauranga Boys' College # Author: Alex Kho # Date: THE DATE YOU COMPLETED THE CODE # Python: 3.5 #------------------------------------------------- import random import time total_rounds = 0 current_round = 1 chips = 0 taken = 0 p1_win = 0 p2_win = 0 turn = 0 while True: player1 = input( "Player 1 name: " ) player2 = input( "Player 2 name: ") if player1.isalpha() == True and player2.isalpha() == True: break else: print( "No, that's not a valid name..." ) print() while True: try: total_rounds = int(input( "How many rounds would you like to play? (1-5): " ) ) if total_rounds > 0 and total_rounds < 6: break else: print() print( "1-5, guys.. lets try again" ) except: print() print( "Thats not a number, buddy." ) print() print( "Take-Away") while current_round < total_rounds + 1: print() print( "Round {}".format(current_round) ) turn = 1 chips = 21 while chips > 0: player_turn = turn % 2 if player_turn == 1: player2 = player1 if player_turn == 0: player1 = player2 while True: try: print() print( "{}'s Turn:".format(player1) ) time.sleep(0.3) print( "Chips: {}".format(chips) ) time.sleep(0.3) taken = int( input( "Take one, two or three chips: " ) ) if taken < 4 and taken > 0: chips = chips - taken turn = turn + 1 break else: print() print( "!Thats not how it works, dimwit!") except: print() print( "Yes, you do need to put a number down." ) #player 1 win check if chips <= 0: current_round = current_round + 1 p1_win = p1_win + 1 break print() print( " FINAL SCORE" ) print( "|========================|" ) print( "{} won {} out of {} games!".format(player1, p1_win, total_rounds) ) print( "{} won {} out of {} games!".format(player2, p2_win, total_rounds) ) print( "|========================|" )