def get_game_value(self) -> float: game_values = [] for my_card in LeducPoker.LeducPokerGame.DECK: opponent_card_probs = np.array([1 / 5] * 6) opponent_card_probs[my_card] = 0 my_infoset = LeducPoker.LeducInfoset(card=my_card, bet_sequences=[(), ()], board_card=None) game_value = self._get_game_state_value(my_infoset, opponent_card_probs) game_values.append(game_value[self.player_num]) return sum(game_values) / len(game_values)
def _get_opponent_game_value( self, my_infoset: LeducPoker.LeducInfoset, opponent_card_probs: np.ndarray) -> np.ndarray: cards_to_action_probs = {} total_action_probs = np.zeros(3) for opponent_card in LeducPoker.LeducPokerGame.DECK: if opponent_card == my_infoset.card or opponent_card == my_infoset.board_card: assert opponent_card_probs[opponent_card] == 0 continue opponent_infoset = LeducPoker.LeducInfoset( card=opponent_card, bet_sequences=my_infoset.bet_sequences, board_card=my_infoset.board_card) action_probs = self.opponent_policy.action_prob(opponent_infoset) if not my_infoset.can_raise: action_probs[PlayerActions.CHECK_CALL] += action_probs[ PlayerActions.BET_RAISE] action_probs[PlayerActions.BET_RAISE] = 0 if not my_infoset.can_fold: action_probs[PlayerActions.CHECK_CALL] += action_probs[ PlayerActions.FOLD] action_probs[PlayerActions.FOLD] = 0 cards_to_action_probs[opponent_card] = action_probs total_action_probs += opponent_card_probs[ opponent_card] * np.array(action_probs) retval = np.zeros(2) for action in PlayerActions.ALL_ACTIONS: if total_action_probs[action] == 0: continue post_action_card_probs = opponent_card_probs.copy() for opponent_card in LeducPoker.LeducPokerGame.DECK: if opponent_card == my_infoset.card or opponent_card == my_infoset.board_card: continue post_action_card_probs[opponent_card] *= cards_to_action_probs[ opponent_card][action] post_action_card_probs = self._normalize(post_action_card_probs) post_action_infoset = copy.deepcopy(my_infoset) post_action_infoset.add_action(action) game_value = self._get_game_state_value(post_action_infoset, post_action_card_probs) retval += game_value * total_action_probs[action] return retval