From 4731c4cd26d7670bfe29fcc6b3d62735a7a325f7 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 2 May 2026 12:27:30 +0200 Subject: [PATCH] apply 'strict tree maps' automatically --- arbitrile.cpp | 11 +++++++++++ archimedean.cpp | 13 +++++++++++++ fake.cpp | 16 ++++++++-------- geom-exp.cpp | 14 ++++++++++++-- rulegen.cpp | 21 +++++++++++++++++++++ system.cpp | 1 + 6 files changed, 66 insertions(+), 10 deletions(-) diff --git a/arbitrile.cpp b/arbitrile.cpp index 11f9f61c..6c26ba91 100644 --- a/arbitrile.cpp +++ b/arbitrile.cpp @@ -1707,6 +1707,8 @@ EX void run(string fname) { catch(connection_debug_request& cr) { launch_connection_debugger(g, t, cr.c, cr.id); } + if(!t.have_tree) rulegen::rules_known_for = "unknown"; + if(!t.have_tree) rulegen::convert_if_appropriate(); start_game(); } @@ -2024,6 +2026,7 @@ EX void convert() { auto& ac = arb::current; ac.order++; ac.filename = full_geometry_name(); + ac.name = "CONVERTED: " + full_geometry_name(); ac.comment = "converted from: " + ac.filename; ac.cscale = cgi.scalefactor; ac.boundary_ratio = 1; @@ -2116,6 +2119,14 @@ EX void activate() { } } +EX void deactivate() { + if(in()) { + println(hlog, "*** DEACTIVATING"); + geometry = base_geometry; + variation = base_variation; + } + } + EX } #if CAP_COMMANDLINE diff --git a/archimedean.cpp b/archimedean.cpp index 47f9a7b5..2fb246e7 100644 --- a/archimedean.cpp +++ b/archimedean.cpp @@ -14,6 +14,15 @@ EX namespace arcm { EX bool in() { return cgflags & qARCHI; } +EX bool in_or_converted() { + if(geometry == gArbitrary) { + dynamicval d1(geometry, arb::convert::base_geometry); + dynamicval d2(variation, arb::convert::base_variation); + return in(); + } + return cgflags & qARCHI; + } + EX ld euclidean_edge_length = .5; #if HDR @@ -1050,6 +1059,7 @@ EX bool load_symbol(const string& s, bool switch_geom) { stop_game(); set_geometry(gArchimedean); current = at; + rulegen::convert_if_appropriate(); if(!delayed_start) start_game(); return true; } @@ -1264,10 +1274,12 @@ archimedean_tiling edited; bool symbol_editing; EX void next_variation() { + if(geometry == gArbitrary) { stop_game(); arb::convert::deactivate(); } set_variation( PURE ? eVariation::dual : DUAL ? eVariation::bitruncated : eVariation::pure); + rulegen::convert_if_appropriate(); start_game(); } @@ -1297,6 +1309,7 @@ EX void enable(archimedean_tiling& arct) { } } #endif + rulegen::convert_if_appropriate(); start_game(); } diff --git a/fake.cpp b/fake.cpp index 52fd4fb9..cbfd55ba 100644 --- a/fake.cpp +++ b/fake.cpp @@ -36,7 +36,7 @@ EX namespace fake { if(WDIM == 2 && standard_tiling() && GOLDBERG && S3 == 4 && gp::param.first == 1 && gp::param.second == 1) return true; if(WDIM == 2 && standard_tiling() && UNRECTIFIED && S3 == 4 && gp::param.first == 1 && gp::param.second == 1) return true; if(WDIM == 2 && standard_tiling() && UNTRUNCATED && S3 == 3 && gp::param.first == 1 && gp::param.second == 1) return true; - if(arcm::in() && PURE) return true; + if(arcm::in_or_converted() && PURE) return true; if(hat::in()) return true; if(WDIM == 2) return false; if(among(geometry, gBitrunc3)) return false; @@ -116,7 +116,7 @@ EX namespace fake { return cgi.emb->base_to_actual(h); } - if(arcm::in() || hat::in()) { + if(arcm::in_or_converted() || hat::in()) { return underlying_map->get_corner(c, cid, cf); } @@ -230,7 +230,7 @@ EX namespace fake { } #if CAP_ARCM - if(arcm::in()) { + if(arcm::in_or_converted()) { int t = arcm::id_of(c->master); int t2 = arcm::id_of(c->move(d)->master); auto& cof = arcm::current_or_fake(); @@ -310,7 +310,7 @@ EX namespace fake { } transmatrix relative_matrixc(cell *h2, cell *h1, const hyperpoint& hint) override { - if(arcm::in()) return underlying_map->relative_matrix(h2, h1, hint); + if(arcm::in_or_converted()) return underlying_map->relative_matrix(h2, h1, hint); if(h1 == h2) return Id; for(int a=0; atype; a++) if(h1->move(a) == h2) @@ -320,7 +320,7 @@ EX namespace fake { } transmatrix relative_matrixh(heptagon *h2, heptagon *h1, const hyperpoint& hint) override { - if(arcm::in()) return underlying_map->relative_matrix(h2, h1, hint); + if(arcm::in_or_converted()) return underlying_map->relative_matrix(h2, h1, hint); return relative_matrix(h2->c7, h1->c7, hint); } @@ -587,7 +587,7 @@ EX ld around; /** @brief the value of 'around' which makes the tiling Euclidean */ EX ld compute_euclidean() { #if CAP_ARCM - if(arcm::in()) return arcm::current.N * 2 / arcm::current.euclidean_angle_sum; + if(arcm::in_or_converted()) return arcm::current.N * 2 / arcm::current.euclidean_angle_sum; #endif if(underlying == gAperiodicHat) return 6; if(WDIM == 2 && BITRUNCATED) return 9 / (4.5 - 3. / S7 - 6. / S6); @@ -612,7 +612,7 @@ EX ld compute_euclidean() { EX ld around_orig() { #if CAP_ARCM - if(arcm::in()) + if(arcm::in_or_converted()) return arcm::current.N; #endif if(hat::in()) return 6; @@ -669,7 +669,7 @@ EX void compute_scale() { geom3::apply_always3_to(ginf[gFake]); }}); - if(arcm::in()) { + if(arcm::in_or_converted()) { ginf[gFake].tiling_name = "(" + ginf[gArchimedean].tiling_name + ")^" + fts(around / around_orig()); return; } diff --git a/geom-exp.cpp b/geom-exp.cpp index 5a45b7fb..58e62dd2 100644 --- a/geom-exp.cpp +++ b/geom-exp.cpp @@ -676,7 +676,7 @@ EX string full_geometry_name() { void action_change_variation() { if(0) ; #if CAP_ARCM - else if(arcm::in()) arcm::next_variation(); + else if(arcm::in_or_converted()) arcm::next_variation(); #endif #if MAXMDIM >= 4 else if(reg3::in() || geometry == gCubeTiling) reg3::configure_variation(); @@ -988,6 +988,16 @@ EX void showEuclideanMenu() { dialog::init(XLAT("experiment with geometry")); + dynamicval d1(geometry, geometry); + dynamicval d2(variation, variation); + + bool converted = false; + if(arb::convert::in() && rulegen::auto_rulegen) { + converted = true; + geometry = arb::convert::base_geometry; + variation = arb::convert::base_variation; + } + dialog::addSelItem(XLAT("geometry"), geometry_name(), 'd'); dialog::add_action([] { pushScreen(ge_select_tiling); pushScreen(ge_select_filter); }); @@ -1021,7 +1031,7 @@ EX void showEuclideanMenu() { } #endif - if(fake::available()) { + if(fake::available() && !converted) { dialog::addItem(XLAT("fake curvature"), '4'); dialog::add_action([] { diff --git a/rulegen.cpp b/rulegen.cpp index 7b36f159..1c714d38 100644 --- a/rulegen.cpp +++ b/rulegen.cpp @@ -11,6 +11,8 @@ namespace hr { EX namespace rulegen { +EX bool auto_rulegen = true; + /* limits */ EX int max_retries = 999; EX int max_tcellcount = 1000000; @@ -2554,6 +2556,8 @@ auto hooks_arg = #endif auto hooks = addHook(hooks_configfile, 100, [] { + param_b(auto_rulegen, "auto_rulegen") + ->editable("auto-use strict tree maps when appropriate", 'a'); param_i(max_retries, "max_retries") ->set_reaction(change_rulegen_params); param_i(max_tcellcount, "max_tcellcount") @@ -2714,6 +2718,8 @@ EX void show() { return; } + add_edit(auto_rulegen); + dialog::addBoolItem(XLAT("in tes internal format"), arb::in(), 't'); dialog::add_action(switch_tes_internal_format); @@ -2814,5 +2820,20 @@ int readRuleArgs() { auto hook = addHook(hooks_args, 100, readRuleArgs); #endif +EX void convert_if_appropriate() { + println(hlog, "*** CONVERT TO RULEGEN"); + if(!auto_rulegen) return; + if(!hyperbolic) return; + println(hlog, "converting"); + if(geometry != gArbitrary) + arb::convert::convert(); + println(hlog, "activating"); + arb::convert::activate(); + println(hlog, "preparing rules"); + + if(!prepare_rules()) return; + println(hlog, "success"); + } + EX } } diff --git a/system.cpp b/system.cpp index c0b71261..1ab49cc2 100644 --- a/system.cpp +++ b/system.cpp @@ -1614,6 +1614,7 @@ EX void set_variation(eVariation target) { if(target != eVariation::pure) { if(bt::in() || sol || aperiodic || WDIM == 3) if(!mproduct) geometry = gNormal; } + arb::convert::deactivate(); auto& cd = ginf[gCrystal]; if(target == eVariation::bitruncated && cryst && cd.sides == 8 && cd.vertex == 4) { cd.vertex = 3;