from ServiceLayer import MasterServiceLayer #------------------------------------------IntaliseVaribales------------------------------------------------------------------------------------- # intlaise all the vriables for use in the main program peglst = [] # Peg Guess list guessNo = 0 answer = False # --------------------------------------------------------MAIN---------------------------------------------------------- print("Welcome to:") print(" ") print(" __ __ _ ____ _____ _____ ____") print(" | \/ | / \ / __ | |_ _| | ___ | | _ \ ") print(" | |\/| | / _ \ \___ \ | | | _| | |_) |") print(" | | | | / ___ \ ___) | | | | |___ | _ < ") print(" |_| |_| /_/ \_\|____/ |_| |_____| |_| \_\ ") print(" ") print(" __ __ _ _ ____ ") print(" | \/ | ___ | \ | | | _ \ ") print(" | |\/| | |_ _| | \| | | | | | ") print(" | | | | | | | |\ | | |_| | ") print(" |_| |_| | | |_| \_| |____/ ") print(" |___|") print(" ") check = True # intalise variable while check == True: # ensure that values are entered before the game continues try: NoOfColours = int(input("How many colours do you want to use 3-8: ")) # error check using type(1) ensures number NoOfPegs = int(input("How many pegs do you want to use 3-8: ")) # error check using type(1) Players = int(input("How many players 1 or 2? (1 = (1 vs Comp) or 2 = (comp Vs comp)): ")) # error check using type(1) if NoOfColours in [3,4,5,6,7,8] and NoOfPegs in [3,4,5,6,7,8]: # if they are in range if Players == 1 or Players ==2: # and the players is one or 2 check = False # end the loop else: print("Enter a number") # print error message else: print("Enter a number") except TypeError: # print error message print("Enter a number") except ValueError: # print error message print("Enter a number") MasterServiceLayer.start(NoOfPegs, NoOfColours, peglst) # call start function if Players == 1: while answer == False and guessNo < 12: # get Player guess # Get black and white clues from guess # See if they have won continue if guessNo == 12 and answer == False: print("You have lost") print("The Answer was: ", peglst) else: while answer == False and guessNo < 12: # get Computer guess # Get black and white clues from guess # See if they have won continue if guessNo == 12 and answer == False: print("You have lost") print("The Answer was: ", peglst)