From 3c231ddc25879929e0532811b14a01d5c9af44d8 Mon Sep 17 00:00:00 2001 From: Emile Date: Sun, 19 Feb 2023 17:22:24 +0100 Subject: limit amount of tests to 100_000 and add CTRL-C handling --- solve.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/solve.py b/solve.py index 6ec7ff3..2cef7ed 100644 --- a/solve.py +++ b/solve.py @@ -455,6 +455,10 @@ def brute_force(level, s, t, goal_s, goal_t): counter += CHUNK_SIZE + # set a limit for the amount of tries we're doing + if counter == 100_000: + return [] + return rands def brute_force_single(level, s, goal_s): @@ -635,6 +639,9 @@ while True: # solve manually else: res = brute_force(level, s, t, goal_s, goal_t) + if res == []: + print("could not find solution in given amount of tries, skipping") + continue print("SOLVE MANUALLY") print(res) @@ -657,6 +664,16 @@ while True: #p.interactive() level += 1 + + # catch CTRL-C for skipping the current testcase, there's a 3 second window + # for pressing CTRL-C again for completely stopping the script + except KeyboardInterrupt: + try: + time.sleep(3) + continue + except KeyboardInterrupt: + exit() + except: print("SOMETHING WENT HORRIBLY WRONG!") -- cgit 1.4.1