def startGame(player: Player, comp: Computer, goalNumber, minStep, maxStep): print("We will count to {}, with minimum increment: {}, and maximum increment: {}".format(goalNumber, minStep, maxStep)) time.sleep(2) currentNumber = 0 level = levelOptions() player.number = comp.number = 0 if isPlayerGoFirst(): player.isTurn = True else: comp.isTurn = True # start the game: while not player.isWinner() and not comp.isWinner(): print("-------------------------------------") print("Current counting is:", currentNumber) if player.isTurn: playerCounting(player=player, currentNumber=currentNumber, minStep=minStep, maxStep=maxStep) else: if level == "easy": comp.guessNumber(currentNumber) else: comp.calculateNumber(currentNumber) time.sleep(0.5) print("{} counts: {} \n".format(comp.name, comp.number)) # toggle turn comp.changeTurn() player.changeTurn() currentNumber = max(comp.number, player.number) else: winner(player, comp)
def demoGame(): # constants currentNumber = 0 minStep = 1 maxStep = 3 goalNumber = 10 # create players comp1 = Computer(goalNumber=goalNumber, minStep=minStep, maxStep=maxStep) comp2 = Computer(goalNumber=goalNumber, minStep=minStep, maxStep=maxStep) comp1.isTurn = True comp1.name = "Computer 1" comp2.name = "Computer 2" print("\n Demo Game!!! \n We will count to 10 \n Start with 0\n") loopCounter = 0 # this counter is even means both players already make their moves # start the game: while currentNumber < goalNumber: if comp1.isTurn: comp1.guessNumber(currentNumber) print("{} counts: {}".format(comp1.name, comp1.number)) else: comp2.guessNumber(currentNumber) print("{} counts: {} \n".format(comp2.name, comp2.number)) currentNumber = max(comp1.number, comp2.number) comp1.changeTurn() comp2.changeTurn() time.sleep(0.5) loopCounter += 1 if loopCounter % 2 == 0: print("-------------------------------------") print("Current counting is:", currentNumber) else: gf.winner(comp1, comp2)