From ee230f4be9dc144315b57d70d881ad9ab595c381 Mon Sep 17 00:00:00 2001 From: Chris Proctor Date: Wed, 11 May 2022 14:25:43 -0400 Subject: [PATCH] Enforce max_depth in strategy --- strategy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/strategy.py b/strategy.py index ca18813..7702ed0 100644 --- a/strategy.py +++ b/strategy.py @@ -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