def fake_move(self, rnd: PlayerRoundCheating, cardToPlay: int) -> PlayerRoundCheating: nextRound = PlayerRoundCheating() nextRound.set_from_round(rnd) nextRound.current_trick[rnd.nr_cards_in_trick] = cardToPlay nextRound.hands[nextRound.player, cardToPlay] = 0 nextRound.nr_cards_in_trick = nextRound.nr_cards_in_trick + 1 nextRound.nr_played_cards = nextRound.nr_played_cards + 1 nextRound.player = (nextRound.player - 1) % 4 nextRound.hand = nextRound.hands[nextRound.player] return nextRound
def play_card(self, rnd: PlayerRoundCheating) -> int: """ Player returns a card to play based on the given round information. Args: rnd: current round Returns: card to play, int encoded """ playerRound = PlayerRoundCheating() playerRound.set_from_round(rnd) cardToPlay = self.alphabeta(playerRound, 0, Move(0, -sys.maxsize), Move(0, sys.maxsize), True) return cardToPlay.get_card()
def simulateRound(self, node: Node): rnd = get_round_from_player_round(node.getAction().getRound(), node.getAction().getRound().hands) rnd.action_play_card(node.getAction().getCard()) cards = rnd.nr_played_cards randomPlayer = RandomPlayerSchieber() while cards < 36: player_rnd = PlayerRoundCheating() player_rnd.set_from_round(rnd) card_action = randomPlayer.play_card(player_rnd) rnd.action_play_card(card_action) cards += 1 myPoints = rnd.points_team_0 pointsEnemy = rnd.points_team_1 maxPoints = myPoints + pointsEnemy if myPoints > pointsEnemy: return (myPoints - 0) / (maxPoints - 0) else: return 0
def __simulate_round(self, node: Node): # Random walk round = get_round_from_player_round(node.getNodeMCTSInformation().getRound(), node.getNodeMCTSInformation().getRound().hands) round.action_play_card(node.getNodeMCTSInformation().getCard()) cards = round.nr_played_cards random_player = MyPlayer() while cards < 36: player_round = PlayerRoundCheating() player_round.set_from_round(round) card_action = random_player.play_card(player_round) round.action_play_card(card_action) cards += 1 myPoints = round.points_team_0 pointsEnemy = round.points_team_1 maxPoints = myPoints + pointsEnemy if myPoints > pointsEnemy: return (myPoints - 0) / (maxPoints - 0) else: return 0