From 86ccbfe78bc267c01c003b9d1694d17ed63fac86 Mon Sep 17 00:00:00 2001 From: Nikolas Date: Fri, 4 Oct 2024 09:35:54 -0700 Subject: [PATCH] small fixes --- harness_utils/keras_service.py | 6 ++-- .../shadowofthetombraider.py | 32 ++++++++++++------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/harness_utils/keras_service.py b/harness_utils/keras_service.py index 71ce1a4..69b63c8 100644 --- a/harness_utils/keras_service.py +++ b/harness_utils/keras_service.py @@ -101,7 +101,7 @@ class KerasService(): def _divide_horizontal(self, screenshot, quadrant: ScreenShotQuadrant): """divide the screenshot horizontally""" - height, _, _ = screenshot.shape + height, _ = screenshot.shape if quadrant == ScreenShotQuadrant.TOP: return screenshot[0:int(height/2), :] if quadrant == ScreenShotQuadrant.BOTTOM: @@ -111,7 +111,7 @@ class KerasService(): def _divide_vertical(self, screenshot, quadrant: ScreenShotQuadrant): """divide the screenshot vertically""" - _, width, _ = screenshot.shape + _, width = screenshot.shape if quadrant == quadrant.LEFT: return screenshot[:, 0:int(width/2)] if quadrant == quadrant.RIGHT: @@ -121,7 +121,7 @@ class KerasService(): def _divide_in_four(self, screenshot, quadrant: ScreenShotQuadrant): """divide the screenshot in four quadrants""" - height, width, _ = screenshot.shape + height, width = screenshot.shape if quadrant == ScreenShotQuadrant.TOP_LEFT: return screenshot[0:int(height/2), 0:int(width/2)] if quadrant == ScreenShotQuadrant.TOP_RIGHT: diff --git a/shadowofthetombraider/shadowofthetombraider.py b/shadowofthetombraider/shadowofthetombraider.py index d72ff94..79c2f6c 100644 --- a/shadowofthetombraider/shadowofthetombraider.py +++ b/shadowofthetombraider/shadowofthetombraider.py @@ -18,7 +18,7 @@ from harness_utils.output import ( DEFAULT_LOGGING_FORMAT, DEFAULT_DATE_FORMAT) from harness_utils.process import terminate_processes -from harness_utils.keras_service import KerasService +from harness_utils.keras_service import KerasService, ScreenShotDivideMethod, ScreenShotQuadrant, ScreenSplitConfig from harness_utils.steam import exec_steam_game from harness_utils.artifacts import ArtifactManager, ArtifactType @@ -48,23 +48,31 @@ def start_game(): def run_benchmark(): """Start game via Steam and enter fullscreen mode""" - setup_start_time = time.time() - start_game() - args = get_args() keras_service = KerasService(args.keras_host, args.keras_port) am = ArtifactManager(LOG_DIR) - if keras_service.wait_for_word(word="options", timeout=30, interval=1) is None: + setup_start_time = time.time() + start_game() + time.sleep(10) + + ss_config = ScreenSplitConfig( + divide_method=ScreenShotDivideMethod.QUADRANT, + quadrant=ScreenShotQuadrant.BOTTOM_RIGHT + ) + + if keras_service.wait_for_word(word="options", timeout=30, interval=1, split_config=ss_config) is None: logging.info("Did not find the options menu. Did the game launch correctly?") sys.exit(1) + logging.info("found options") + user.press("up") - time.sleep(0.2) + time.sleep(0.5) user.press("up") - time.sleep(0.2) + time.sleep(0.5) user.press("up") - time.sleep(0.2) + time.sleep(0.5) user.press("enter") time.sleep(1) @@ -72,12 +80,14 @@ def run_benchmark(): logging.info("Did not find the graphics menu. Did the menu get stuck?") sys.exit(1) + logging.info("found graphics") + user.press("down") - time.sleep(0.2) + time.sleep(0.5) user.press("down") - time.sleep(0.2) + time.sleep(0.5) user.press("down") - time.sleep(0.2) + time.sleep(0.5) user.press("enter") time.sleep(1)