Exemple #1
0
 def test_joint_action_probabilities_failure_on_seq_game(self):
     """Test failure of child on sequential games."""
     game = pyspiel.load_game("kuhn_poker")
     with self.assertRaises(AssertionError):
         list(
             policy.joint_action_probabilities(
                 game.new_initial_state(),
                 policy.UniformRandomPolicy(game)))
def _transitions(state, policies):
    """Returns iterator over (action, prob) from the given state."""
    if state.is_chance_node():
        return state.chance_outcomes()
    elif state.is_simultaneous_node():
        return policy.joint_action_probabilities(state, policies)
    else:
        player = state.current_player()
        return policies[player].action_probabilities(state).items()
Exemple #3
0
 def test_joint_action_probabilities(self):
     """Test expected behavior of joint_action_probabilities."""
     game = pyspiel.load_game("python_iterated_prisoners_dilemma")
     uniform_policy = policy.UniformRandomPolicy(game)
     joint_action_probs = policy.joint_action_probabilities(
         game.new_initial_state(), uniform_policy)
     self.assertCountEqual(list(joint_action_probs), [
         ((0, 0), 0.25),
         ((1, 1), 0.25),
         ((1, 0), 0.25),
         ((0, 1), 0.25),
     ])