diff --git a/cyberpunk2077/cyberpunk2077.py b/cyberpunk2077/cyberpunk2077.py index 87369a6..c73910d 100644 --- a/cyberpunk2077/cyberpunk2077.py +++ b/cyberpunk2077/cyberpunk2077.py @@ -26,7 +26,6 @@ SCRIPT_DIRECTORY = os.path.dirname(os.path.realpath(__file__)) LOG_DIRECTORY = os.path.join(SCRIPT_DIRECTORY, "run") PROCESS_NAME = "cyberpunk2077.exe" - user.FAILSAFE = False def start_game(): @@ -64,6 +63,25 @@ def check_for_rt(): user.press("down") am.take_screenshot("graphics_pt.png", ArtifactType.CONFIG_IMAGE, "graphics menu path tracing") +def check_anisotropy(max_attempts=10): + """Continuously looks for a word using kerasService. If not found in the given time, presses a button. + """ + for _ in range(max_attempts): + # Try finding the word within check_duration seconds + found = kerasService.look_for_word(word="anisotropy", attempts=10, interval=0.5) + + if found: + return True # Stop checking + + # If not found, press the button once + user.press("down") + + # Short delay before rechecking + time.sleep(0.5) + + logging.info("Max attempts reached for checking the camera. Did the game load the save?") + sys.exit(1) # Word was not found + def navigate_settings() -> None: """Simulate inputs to navigate the main menu""" navigate_to_settings() @@ -115,10 +133,8 @@ def navigate_settings() -> None: user.press("down") time.sleep(0.5) - result = kerasService.wait_for_word("anisotropy", interval=3, timeout=20) - if not result: - logging.info("Did not see anisotropic options. Did the game navigate the graphics menu correctly?") - sys.exit(1) + check_anisotropy() + am.take_screenshot("graphics_2.png", ArtifactType.CONFIG_IMAGE, "graphics menu 2") for _ in range(11): diff --git a/shadowofthetombraider/shadowofthetombraider.py b/shadowofthetombraider/shadowofthetombraider.py index 85d41c6..c68d011 100644 --- a/shadowofthetombraider/shadowofthetombraider.py +++ b/shadowofthetombraider/shadowofthetombraider.py @@ -53,6 +53,9 @@ def run_benchmark(keras_service, am): start_game() time.sleep(10) + if keras_service.wait_for_word(word="unavailable", timeout=30, interval=1): + user.press("enter") + ss_config = ScreenSplitConfig( divide_method=ScreenShotDivideMethod.HORIZONTAL, quadrant=ScreenShotQuadrant.TOP @@ -106,8 +109,8 @@ def run_benchmark(keras_service, am): elapsed_setup_time = round(int(time.time()) - setup_start_time, 2) logging.info("Setup took %f seconds", elapsed_setup_time) - if keras_service.wait_for_word(word="fps", timeout=30, interval=0.5) is None: - logging.info("Did not find the benchmark option on the screen. Did the menu get stuck?") + if keras_service.wait_for_word(word="fps", timeout=60, interval=0.5) is None: + logging.info("Did not find the FPS counter. Did the benchmark crash?") sys.exit(1) test_start_time = int(time.time())