1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-06-11 19:04:08 +00:00

more stable rulegen params

This commit is contained in:
Zeno Rogue 2025-05-11 12:03:45 +02:00
parent bcfacd2e9f
commit bcb232b191
2 changed files with 80 additions and 45 deletions

View File

@ -1125,9 +1125,11 @@ EX void initConfig() {
-> editable("simplified display of apeirogons", 'f') -> editable("simplified display of apeirogons", 'f')
-> help("Connect the ends of the apeirogon segment with the boundary point using straight lines. This should be faster and, in most cases, actually more correct."); -> help("Connect the ends of the apeirogon segment with the boundary point using straight lines. This should be faster and, in most cases, actually more correct.");
param_b(arb::convert::minimize_on_convert, "tes_minimize_on_convert", false) param_b(arb::convert::minimize_on_convert, "tes_minimize_on_convert", false)
-> editable("consider all symmetries when converting", 'm'); -> editable("consider all symmetries when converting", 'm')
-> set_reaction(rulegen::change_minimize_on_convert);
param_b(arb::convert::reverse_order, "tes_reverse_order", false) param_b(arb::convert::reverse_order, "tes_reverse_order", false)
-> editable("tes reverse order on convert", 'r'); -> editable("tes reverse order on convert", 'r')
-> set_reaction(rulegen::change_rulegen_params);
param_b(display_yasc_codes, "yasc", false) param_b(display_yasc_codes, "yasc", false)
-> editable("YASC codes", 'Y') -> editable("YASC codes", 'Y')

View File

@ -2539,16 +2539,25 @@ auto hooks_arg =
#endif #endif
auto hooks = addHook(hooks_configfile, 100, [] { auto hooks = addHook(hooks_configfile, 100, [] {
param_i(max_retries, "max_retries"); param_i(max_retries, "max_retries")
->set_reaction(change_rulegen_params);
param_i(max_tcellcount, "max_tcellcount") param_i(max_tcellcount, "max_tcellcount")
->editable(0, 16000000, 100000, "maximum cellcount", "controls the max memory usage of conversion algorithm -- the algorithm fails if exceeded", 'c'); ->editable(0, 16000000, 100000, "maximum cellcount", "controls the max memory usage of conversion algorithm -- the algorithm fails if exceeded", 'c')
param_i(max_adv_steps, "max_adv_steps"); ->set_reaction(change_rulegen_params);
param_i(max_examine_branch, "max_examine_branch"); param_i(max_adv_steps, "max_adv_steps")
param_i(max_getside, "max_getside"); ->set_reaction(change_rulegen_params);
param_i(max_bdata, "max_bdata"); param_i(max_examine_branch, "max_examine_branch")
param_i(max_shortcut_length, "max_shortcut_length"); ->set_reaction(change_rulegen_params);
param_i(rulegen_timeout, "rulegen_timeout"); param_i(max_getside, "max_getside")
param_i(first_restart_on, "first_restart_on"); ->set_reaction(change_rulegen_params);
param_i(max_bdata, "max_bdata")
->set_reaction(change_rulegen_params);
param_i(max_shortcut_length, "max_shortcut_length")
->set_reaction(change_rulegen_params);
param_i(rulegen_timeout, "rulegen_timeout")
->set_reaction(change_rulegen_params);
param_i(first_restart_on, "first_restart_on")
->set_reaction(change_rulegen_params);
#if MAXMDIM >= 4 #if MAXMDIM >= 4
param_i(max_ignore_level_pre, "max_ignore_level_pre"); param_i(max_ignore_level_pre, "max_ignore_level_pre");
param_i(max_ignore_level_post, "max_ignore_level_post"); param_i(max_ignore_level_post, "max_ignore_level_post");
@ -2608,6 +2617,41 @@ EX void verify_parsed_treestates(arb::arbi_tiling& c) {
find_possible_parents(); find_possible_parents();
} }
EX void prepare_rules_and_restart() {
if(!prepare_rules()) return;
println(hlog, "prepare_rules returned true");
stop_game();
arb::convert::activate();
start_game();
delete_tmap();
}
EX void switch_tes_internal_format() {
if(!arb::in()) {
try {
arb::convert::convert();
arb::convert::activate();
start_game();
rule_status = XLAT("converted successfully -- %1 cell types", its(isize(arb::current.shapes)));
rules_known_for = "unknown";
}
catch(hr_parse_exception& ex) {
println(hlog, "failed: ", ex.s);
rule_status = XLAT("failed to convert: ") + ex.s;
rules_known_for = "unknown";
}
}
else if(arb::convert::in()) {
stop_game();
geometry = arb::convert::base_geometry;
variation = arb::convert::base_variation;
start_game();
}
else {
addMessage(XLAT("cannot be disabled for this tiling"));
}
}
EX void show() { EX void show() {
cmode = sm::SIDE | sm::MAYDARK; cmode = sm::SIDE | sm::MAYDARK;
gamescreen(); gamescreen();
@ -2655,31 +2699,7 @@ EX void show() {
} }
dialog::addBoolItem(XLAT("in tes internal format"), arb::in(), 't'); dialog::addBoolItem(XLAT("in tes internal format"), arb::in(), 't');
dialog::add_action([] { dialog::add_action(switch_tes_internal_format);
if(!arb::in()) {
try {
arb::convert::convert();
arb::convert::activate();
start_game();
rule_status = XLAT("converted successfully -- %1 cell types", its(isize(arb::current.shapes)));
rules_known_for = "unknown";
}
catch(hr_parse_exception& ex) {
println(hlog, "failed: ", ex.s);
rule_status = XLAT("failed to convert: ") + ex.s;
rules_known_for = "unknown";
}
}
else if(arb::convert::in()) {
stop_game();
geometry = arb::convert::base_geometry;
variation = arb::convert::base_variation;
start_game();
}
else {
addMessage(XLAT("cannot be disabled for this tiling"));
}
});
dialog::addBoolItem(XLAT("extended football colorability"), arb::extended_football, 'f'); dialog::addBoolItem(XLAT("extended football colorability"), arb::extended_football, 'f');
dialog::add_action([] { dialog::add_action([] {
@ -2688,6 +2708,8 @@ EX void show() {
rule_status = "manually disabled"; rule_status = "manually disabled";
if(arb::convert::in()) { if(arb::convert::in()) {
stop_game(); stop_game();
geometry = arb::convert::base_geometry;
variation = arb::convert::base_variation;
arb::convert::convert(); arb::convert::convert();
arb::convert::activate(); arb::convert::activate();
start_game(); start_game();
@ -2706,15 +2728,7 @@ EX void show() {
add_edit(arb::convert::minimize_on_convert); add_edit(arb::convert::minimize_on_convert);
dialog::addBoolItem(XLAT("strict tree maps"), currentmap->strict_tree_rules(), 's'); dialog::addBoolItem(XLAT("strict tree maps"), currentmap->strict_tree_rules(), 's');
dialog::add_action([] { dialog::add_action([] {
if(!currentmap->strict_tree_rules()) { if(!currentmap->strict_tree_rules()) prepare_rules_and_restart();
if(prepare_rules()) {
println(hlog, "prepare_rules returned true");
stop_game();
arb::convert::activate();
start_game();
delete_tmap();
}
}
else if(arb::current.have_tree) { else if(arb::current.have_tree) {
addMessage(XLAT("cannot be disabled for this tiling")); addMessage(XLAT("cannot be disabled for this tiling"));
} }
@ -2738,6 +2752,25 @@ EX void show() {
dialog::display(); dialog::display();
} }
EX void change_rulegen_params() {
bool b = currentmap->strict_tree_rules();
if(b) {
rulegen::rules_known_for = "unknown";
prepare_rules_and_restart();
}
else rulegen::rules_known_for = "unknown";
}
EX void change_minimize_on_convert() {
bool s = currentmap->strict_tree_rules();
if(arb::convert::in()) {
rules_known_for = "unknown";
switch_tes_internal_format();
switch_tes_internal_format();
if(s) prepare_rules_and_restart();
}
}
#if CAP_COMMANDLINE #if CAP_COMMANDLINE
int readRuleArgs() { int readRuleArgs() {
using namespace arg; using namespace arg;