Skip to content

Commit

Permalink
Enable no legal actions in eval state
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoCabannes authored Jun 19, 2021
1 parent 7d29d4c commit ad65cde
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions open_spiel/python/mfg/algorithms/best_response_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,14 @@ def eval_state(self, state):
return self._state_value[state_str]
else:
assert int(state.current_player()) >= 0, "The player id should be >= 0"
max_q = max(
self.eval_state(state.child(action))
for action in state.legal_actions())
state_legal_actions = state.legal_actions()
if state_legal_actions:
max_q = max(
self.eval_state(state.child(action))
for action in state.legal_actions())
else:
# If no legal action 0 should be played.
max_q = self.eval_state(state.child(0))
self._state_value[state_str] = state.rewards()[
state.mean_field_population()] + max_q
return self._state_value[state_str]
Expand Down

0 comments on commit ad65cde

Please sign in to comment.