From a1fbfb29464820a98da70920bd580cef6e10c8ed Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Wed, 27 Nov 2019 00:43:30 +0100 Subject: [PATCH] gp:: adjm to fix the confusion in quotient spaces --- cell.cpp | 1 + geometry2.cpp | 16 +++++++++++++++- goldberg.cpp | 23 +++++++++++++++++++++++ system.cpp | 1 + 4 files changed, 40 insertions(+), 1 deletion(-) diff --git a/cell.cpp b/cell.cpp index f4dd7cbf..5ecabfa5 100644 --- a/cell.cpp +++ b/cell.cpp @@ -1168,6 +1168,7 @@ EX void clearCellMemory() { dists_computed.clear(); keep_distances_from.clear(); perma_distances = 0; pd_from = NULL; + gp::gp_adj.clear(); } auto cellhooks = addHook(clearmemory, 500, clearCellMemory); diff --git a/geometry2.cpp b/geometry2.cpp index 5118acd8..ccfb4017 100644 --- a/geometry2.cpp +++ b/geometry2.cpp @@ -337,13 +337,27 @@ EX transmatrix iddspin(cell *c, int d, ld bonus IS(0)) { return currentmap->spin EX ld cellgfxdist(cell *c, int d) { return currentmap->spacedist(c, d); } double hrmap_standard::spacedist(cell *c, int i) { - if(NONSTDVAR) return hrmap::spacedist(c, i); + if(NONSTDVAR || WDIM == 3) return hrmap::spacedist(c, i); if(!BITRUNCATED) return cgi.tessf; if(c->type == S6 && (i&1)) return cgi.hexhexdist; return cgi.crossf; } +int neighborId(heptagon *h1, heptagon *h2) { + for(int i=0; itype; i++) if(h1->move(i) == h2) return i; + return -1; + } + transmatrix hrmap_standard::adj(cell *c, int i) { + if(GOLDBERG && gp::do_adjm) { + transmatrix T = master_relative(c, true); + transmatrix U = master_relative(c->cmove(i), false); + if(gp::gp_adj.count({c,i})) { + return T * gp::gp_adj[{c, i}] * U; + } + else + println(hlog, "gpadj not found"); + } if(NONSTDVAR) return calc_relative_matrix(c->cmove(i), c, C0); double d = cellgfxdist(c, i); transmatrix T = ddspin(c, i) * xpush(d); diff --git a/goldberg.cpp b/goldberg.cpp index 1183d818..209935d1 100644 --- a/goldberg.cpp +++ b/goldberg.cpp @@ -82,6 +82,7 @@ EX namespace gp { signed char rdir; signed char mindir; loc start; + transmatrix adjm; }; EX int fixg6(int x) { return (x + MODFIXER) % SG6; } @@ -197,6 +198,8 @@ EX namespace gp { } return false; } + + EX bool do_adjm; void conn1(loc at, int dir, int dir1) { auto& wc = get_mapping(at); @@ -209,11 +212,13 @@ EX namespace gp { if(peek(wcw)) { DEBB0(DF_GP, ("(pulled) "); ) set_localwalk(wc1, dir1, wcw + wstep); + if(do_adjm) wc1.adjm = wc.adjm * gp_adj[{wcw.at, wcw.spin}]; } else { peek(wcw) = newCell(SG6, wc.cw.at->master); wcw.at->c.setspin(wcw.spin, 0, false); set_localwalk(wc1, dir1, wcw + wstep); + if(do_adjm) wc1.adjm = wc.adjm; spawn++; DEBB0(DF_GP, ("(created) "); ) } @@ -237,6 +242,10 @@ EX namespace gp { exit(1); } } + if(do_adjm) { + gp_adj[{wcw.at, wcw.spin}] = inverse(wc.adjm) * wc1.adjm; + gp_adj[{wcw1.at, wcw1.spin}] = inverse(wc1.adjm) * wc.adjm; + } } void conn(loc at, int dir) { @@ -244,6 +253,8 @@ EX namespace gp { conn1(at + eudir(dir), fixg6(dir+SG3), fixg6(dir)); } + EX map, transmatrix> gp_adj; + goldberg_mapping_t& set_heptspin(loc at, heptspin hs) { auto& ac0 = get_mapping(at); ac0.cw = cellwalker(hs.at->c7, hs.spin, hs.mirrored); @@ -299,6 +310,18 @@ EX namespace gp { if(S3 == 4) { set_heptspin(vc[2], hs + wstep - 1 + wstep + 1).mindir = -3; } + + do_adjm = quotient; + if(do_adjm) { + auto m = (hrmap_standard*)currentmap; + get_mapping(vc[0]).adjm = Id; + get_mapping(vc[1]).adjm = m->adj(c->master, d); + get_mapping(vc[S3-1]).adjm = m->adj(c->master, (d+1)%c->master->type); + if(S3 == 4) { + heptspin hs1 = hs + wstep - 1; + get_mapping(vc[2]).adjm = m->adj(c->master, d) * m->adj(hs1.at, hs1.spin); + } + } if(S3 == 4 && param == loc(1,1)) { conn(loc(0,0), 1); diff --git a/system.cpp b/system.cpp index 30063bca..a0696c8b 100644 --- a/system.cpp +++ b/system.cpp @@ -1526,6 +1526,7 @@ addHook(hooks_gamedata, 0, [] (gamedata* gd) { gd->store(last_gravity_state); gd->store(shpos); gd->store(cshpos); + gd->store(gp::do_adjm); }) + addHook(hooks_removecells, 0, [] () { eliminate_if(crush_next, is_cell_removed);