Enforce max_depth in strategy
This commit is contained in:
parent
fa5b4c6c1a
commit
ee230f4be9
|
@ -77,8 +77,8 @@ class LookaheadStrategy:
|
||||||
reached, assuming all players are using this Strategy.
|
reached, assuming all players are using this Strategy.
|
||||||
"""
|
"""
|
||||||
reward = self.game.get_reward(state)
|
reward = self.game.get_reward(state)
|
||||||
if not self.game.is_over(state):
|
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)
|
action = self.choose_action(state, depth=depth+1)
|
||||||
future_state = self.game.get_next_state(state, action)
|
future_state = self.game.get_next_state(state, action)
|
||||||
reward += self.get_current_and_future_reward(future_state, depth=depth+1)
|
reward += self.get_current_and_future_reward(future_state, depth=depth+1)
|
||||||
return reward
|
return reward
|
||||||
|
|
Loading…
Reference in New Issue