From 29f2570662934296842d370a03dd433cfda9c650 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 22 Aug 2021 00:12:22 +0200 Subject: [PATCH] rulegen:: timeout feature --- rulegen.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rulegen.cpp b/rulegen.cpp index 121e89c2..35c316d6 100644 --- a/rulegen.cpp +++ b/rulegen.cpp @@ -18,6 +18,7 @@ EX int max_adv_steps = 100; EX int max_examine_branch = 5040; EX int max_bdata = 1000; EX int max_getside = 10000; +EX int rulegen_timeout = 60; #if HDR /** exception thrown by this algoritm in case of any problems */ @@ -1556,6 +1557,7 @@ void clear_all() { EX void generate_rules() { + int t = SDL_GetTicks(); delete_tmap(); if(!arb::in()) try { @@ -1590,6 +1592,8 @@ EX void generate_rules() { important = t_origin; while(true) { + if(SDL_GetTicks() > t + 1000 * rulegen_timeout) + throw rulegen_surrender("timeout"); try { rules_iteration(); break; @@ -1862,6 +1866,7 @@ auto hooks = addHook(hooks_configfile, 100, [] { param_i(max_examine_branch, "max_examine_branch"); param_i(max_getside, "max_getside"); param_i(max_bdata, "max_bdata"); + param_i(rulegen_timeout, "rulegen_timeout"); }); EX void parse_treestate(arb::arbi_tiling& c, exp_parser& ep) {