From 0342b377f76f83aa83362dd4eb1164e87d557901 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Wed, 19 May 2021 12:17:44 +0200 Subject: [PATCH] honeycomb-rule-generator:: exh option to generate ideal honeycombs too --- devmods/honeycomb-rule-generator.cpp | 52 +++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/devmods/honeycomb-rule-generator.cpp b/devmods/honeycomb-rule-generator.cpp index 2027568c..2b1da34f 100644 --- a/devmods/honeycomb-rule-generator.cpp +++ b/devmods/honeycomb-rule-generator.cpp @@ -35,6 +35,8 @@ This algorithm works as follows: namespace hr { +int exh; + map > rules; /** \brief S7 -- for efficiency this is a fixed constant */ @@ -139,8 +141,8 @@ struct ext_nei_rules_t { /** ext_nei_rules_t need to be created only once for each get_id */ map ext_nei_rules; -/** aux recursive function of construct_rules */ -void listnear(cell *c, ext_nei_rules_t& e, const transmatrix& T, int id, set& visi) { +/** aux recursive function of construct_rules: the compact variant */ +void listnear_compact(cell *c, ext_nei_rules_t& e, const transmatrix& T, int id, set& visi) { visi.insert(c); int a = 0, b = 0; for(int i=0; i dist; + map origdir; + vector lst; + + println(hlog, "called listnear_exh for: ", c); + + auto enqueue = [&] (cell *c, int d, int od) { + if(dist.count(c)) return; + dist[c] = d; + origdir[c] = od; + lst.push_back(c); + }; + + enqueue(c, 0, -1); + for(int k=0; k= 0 && !cgi.dirs_adjacent[i][odi]) continue; + cell *c1 = ca->cmove(i); + e.from.push_back(k); + e.dir.push_back(i); + e.original.push_back(!dist.count(c1)); + if(e.original.back() && di < maxdist) + enqueue(c1, di, ca->c.spin(i)); } } } @@ -167,8 +201,13 @@ void construct_rules(cell *c, ext_nei_rules_t& e) { e.from = {-1}; e.dir = {-1}; e.original = {1}; - set visi; - listnear(c, e, Id, 0, visi); + if(!exh) { + set visi; + listnear_compact(c, e, Id, 0, visi); + } + else { + listnear_exh(c, e, exh); + } int orgc = 0; for(auto i: e.original) orgc += i; println(hlog, "id ", get_id(c), " list length = ", isize(e.original), " original = ", orgc); @@ -480,6 +519,9 @@ auto fqhook = else if(argis("-extra-verification")) { reg3::extra_verification++; } + else if(argis("-exh")) { + shift(); exh = argi(); + } else if(argis("-no-rule")) { reg3::reg3_rule_available = false; }