def __playRound(self, player: Player): cards, card3 = deal() bet = 1 + player.play(cards[0], cards[1]) if (cards[0] < card3 and card3 < cards[1]): player.changeScore(bet) else: player.changeScore(-bet)
def turn(player1: Player, player2: Player, i: int, mistakeRate: int): """Play one turn between two player :param player1: Player 1 :param player2: Player 2 :param i: The number of the turn :return: None """ print("Turn {} : ".format(i+1), end="") if i == 0: player1.play('C', mistakeRate) player2.play('C', mistakeRate) else : player1.play(player2.choice[-1], mistakeRate) player2.play(player1.choice[-2], mistakeRate) print("Player 1 [{}] || Player 2 [{}]".format(player1.choice[-1],player2.choice[-1])) gain(player1, player2)
def fastTurn(player1: Player, player2 : Player, max_turn : int, mistakeRate: int): """Play all the turns between two player without printing trace :param player1: Player 1 :param player2: Player 2 :param max_turn: The number of turn of a confrontation :return: None """ n = 0 while n < max_turn : if n == 0: player1.play('C', mistakeRate) player2.play('C', mistakeRate) else : player1.play(player2.choice[-1], mistakeRate) player2.play(player1.choice[-2], mistakeRate) gain(player1, player2, False) n+= 1 print("Player", player1.name, ":", player1.get_score(), "\nPlayer {} : {}\n".format(player2.name, player2.get_score())) # Empty the players' list of choice for next match player1.reset() player2.reset()