Enforce max_depth in strategy

This commit is contained in:
Chris Proctor 2022-05-11 14:25:43 -04:00
parent fa5b4c6c1a
commit ee230f4be9
1 changed files with 2 additions and 2 deletions

View File

@ -77,8 +77,8 @@ class LookaheadStrategy:
reached, assuming all players are using this Strategy.
"""
reward = self.game.get_reward(state)
if not self.game.is_over(state):
action = self.choose_action(state, depth=depth)
if (self.max_depth is None or depth <= self.max_depth) and not self.game.is_over(state):
action = self.choose_action(state, depth=depth+1)
future_state = self.game.get_next_state(state, action)
reward += self.get_current_and_future_reward(future_state, depth=depth+1)
return reward