diff --git a/open_spiel/python/algorithms/noisy_policy.py b/open_spiel/python/algorithms/noisy_policy.py index 803b3cbbe7..f12ae1dc71 100644 --- a/open_spiel/python/algorithms/noisy_policy.py +++ b/open_spiel/python/algorithms/noisy_policy.py @@ -113,11 +113,11 @@ def action_probabilities(self, state, player_id=None): # If self._player_id is None, or if self.player_id == current_player, add # noise. - if (not self.player_id) or (state.current_player() == self.player_id): + if (self.player_id is None) or (state.current_player() == self.player_id): noise_probs = self.get_or_create_noise(state) probs = self._policy.action_probabilities(state, player_id) probs = self.mix_probs(probs, noise_probs) return probs # Send the default probabilities for all other players - return self._policy.action_probabilities(state, player_id) + return self._policy.action_probabilities(state) diff --git a/open_spiel/python/algorithms/noisy_policy_test.py b/open_spiel/python/algorithms/noisy_policy_test.py index 2afcdd825b..adc357bfab 100644 --- a/open_spiel/python/algorithms/noisy_policy_test.py +++ b/open_spiel/python/algorithms/noisy_policy_test.py @@ -40,15 +40,21 @@ def test_cpp_and_python_implementations_are_identical(self, game_name): to_string=lambda s: s.information_state_string()) for current_player in range(game.num_players()): - noise = noisy_policy.NoisyPolicy(policy, 0, alpha=0.5, beta=10.) + noise = noisy_policy.NoisyPolicy( + policy, player_id=current_player, alpha=0.5, beta=10.) for state in all_states.values(): - if state.current_player() != current_player: + if state.current_player() < 0: continue - # TODO(b/141737795): Decide what to do about this. - self.assertNotEqual( - policy.action_probabilities(state), - noise.action_probabilities(state)) + if state.current_player() != current_player: + self.assertEqual( + policy.action_probabilities(state), + noise.action_probabilities(state)) + else: + # TODO(b/141737795): Decide what to do about this. + self.assertNotEqual( + policy.action_probabilities(state), + noise.action_probabilities(state)) if __name__ == "__main__": absltest.main()