From 233adddd36bf9a8a6fa71cdcc0e13c4f1e5833a6 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 5 Apr 2020 10:53:34 +0200 Subject: [PATCH] moved reg3 values to cgi --- barriers.cpp | 4 +- bigstuff.cpp | 6 +- crystal.cpp | 10 +-- fieldpattern.cpp | 20 +++--- geometry.cpp | 25 +++++++ polygons.cpp | 7 +- reg3.cpp | 168 +++++++++++++++++++++-------------------------- 7 files changed, 122 insertions(+), 118 deletions(-) diff --git a/barriers.cpp b/barriers.cpp index 6520fc76..3bc8c4e5 100644 --- a/barriers.cpp +++ b/barriers.cpp @@ -760,7 +760,7 @@ EX void extend3D(cell *c) { cw1.at->bardir = cw1.spin; } - for(int j=0; jbardir != NODIR) return false; for(int j=0; jcmove(j); - if(reg3::dirs_adjacent[bb.spin][j] && bb.at->move(j)) { + if(cgi.dirs_adjacent[bb.spin][j] && bb.at->move(j)) { cellwalker bb2 = reg3::strafe(bb, j); if(listed_cells.count(bb2.at)) continue; listed_cells.insert(bb2.at); diff --git a/bigstuff.cpp b/bigstuff.cpp index 0456b26b..7a8c4581 100644 --- a/bigstuff.cpp +++ b/bigstuff.cpp @@ -202,7 +202,7 @@ void hrmap::generateAlts(heptagon *h, int levs, bool link_cdata) { #if MAXMDIM >= 4 EX int hrandom_adjacent(int d) { vector choices = {d}; - for(int a=0; alandparam != c->landparam-1) continue; if(!cw.at->landflags) continue; if(S7 == 6) c->landflags = 1; - else for(int j=0; jmove(j) && cw.at->move(j)->landparam == c->landparam - 2 && !reg3::dirs_adjacent[j][cw.spin]) + else for(int j=0; jmove(j) && cw.at->move(j)->landparam == c->landparam - 2 && !cgi.dirs_adjacent[j][cw.spin]) if(c->landparam == 2 ? cw.at->move(j)->land != laEndorian : cw.at->move(j)->landparam) c->landflags = 1; } @@ -717,7 +717,7 @@ EX void buildEquidistant(cell *c) { if(cw.at->landparam != c->landparam-1) continue; if(!cw.at->landflags) continue; if(S7 == 6) c->landflags = 1; - else for(int j=0; jmove(j) && cw.at->move(j)->landparam == c->landparam - 2 && !reg3::dirs_adjacent[j][cw.spin] && cw.at->move(j)->landflags) + else for(int j=0; jmove(j) && cw.at->move(j)->landparam == c->landparam - 2 && !cgi.dirs_adjacent[j][cw.spin] && cw.at->move(j)->landflags) c->landflags = 1; } } diff --git a/crystal.cpp b/crystal.cpp index 6765a9e4..5c299558 100644 --- a/crystal.cpp +++ b/crystal.cpp @@ -622,27 +622,27 @@ struct hrmap_crystal : hrmap_standard { for(int a=0; a>1) & 1); id = S7*id + d; if(adjs.count(id)) return adjs[id]; - transmatrix T = reg3::adjmoves[d]; + transmatrix T = cgi.adjmoves[d]; reg3::generate_cellrotations(); auto st = get_canonical(co); auto co1 = co + st[d]; auto st1 = get_canonical(co1); int qty = 0; transmatrix res; - ld gdist = S7 == 12 ? hdist0(tC0(reg3::adjmoves[0])) : reg3::strafedist; + ld gdist = S7 == 12 ? hdist0(tC0(cgi.adjmoves[0])) : cgi.strafedist; for(auto& cr: cgi.cellrotations) { transmatrix U = T * cr.M; - ld go = hdist0(U * tC0(reg3::adjmoves[h->c.spin(d)])); + ld go = hdist0(U * tC0(cgi.adjmoves[h->c.spin(d)])); if(go > 1e-2) continue; for(int s=0; s gdist + .1) + if(hdist(U * tC0(cgi.adjmoves[t]), tC0(cgi.adjmoves[s])) > gdist + .1) goto wrong; } res = U; diff --git a/fieldpattern.cpp b/fieldpattern.cpp index 9f41c782..8b718c51 100644 --- a/fieldpattern.cpp +++ b/fieldpattern.cpp @@ -482,8 +482,8 @@ bool fpattern::generate_all3() { add1(Id); fullv = {hr::Id}; for(int i=0; i fails(N); @@ -516,18 +516,18 @@ int fpattern::solve3() { for(auto& M: iso3) { if(check_order(M, 2)) possible_X.push_back(M); - if(check_order(M, reg3::r_order)) + if(check_order(M, cgi.r_order)) possible_R.push_back(M); } for(auto& M: iso4) if(check_order(M, 2)) possible_P.push_back(M); - DEBB(DF_FIELD, ("field = ", Field, " #P = ", isize(possible_P), " #X = ", isize(possible_X), " #R = ", isize(possible_R), " r_order = ", reg3::r_order, " xp_order = ", reg3::xp_order)); + DEBB(DF_FIELD, ("field = ", Field, " #P = ", isize(possible_P), " #X = ", isize(possible_X), " #R = ", isize(possible_R), " r_order = ", cgi.r_order, " xp_order = ", cgi.xp_order)); for(auto& xX: possible_X) - for(auto& xP: possible_P) if(check_order(mmul(xP, xX), reg3::xp_order)) - for(auto& xR: possible_R) if(check_order(mmul(xR, xX), reg3::rx_order)) { // if(xR[0][0] == 1 && xR[0][1] == 0) + for(auto& xP: possible_P) if(check_order(mmul(xP, xX), cgi.xp_order)) + for(auto& xR: possible_R) if(check_order(mmul(xR, xX), cgi.rx_order)) { // if(xR[0][0] == 1 && xR[0][1] == 0) #if CAP_THREAD if(dis) dis->check_suspend(); if(dis && dis->stop_it) return 0; @@ -535,9 +535,9 @@ int fpattern::solve3() { auto by = [&] (char ch) -> matrix& { return ch == 'X' ? xX : ch == 'R' ? xR : xP; }; for(int i=0; itmatrices[parent->fieldval][d] : adjmoves[d]); + transmatrix T = p1.second * (quotient_map ? quotient_map->tmatrices[parent->fieldval][d] : cgi.adjmoves[d]); #else - transmatrix T = p1.second * adjmoves[d]; + transmatrix T = p1.second * cgi.adjmoves[d]; #endif transmatrix T1 = T; if(hyperbolic) { @@ -724,7 +715,7 @@ EX namespace reg3 { } #endif for(int d2=0; d2 worst_error2) println(hlog, format("worst_error2 = %lg", double(worst_error2 = err))); if(p2.first->move(d2)) println(hlog, "error: repeated edge"); @@ -737,7 +728,7 @@ EX namespace reg3 { println(hlog, "found fb = ", fb); println(hlog, old); for(int d2=0; d2c.connect(d, parent, d, false); return parent; @@ -866,7 +857,7 @@ EX namespace reg3 { } vector get_vertices(cell* c) override { - return vertices_only; + return cgi.vertices_only; } }; @@ -979,7 +970,6 @@ EX namespace reg3 { else if(ginf[geometry].vertex == 5) load_ruleset("honeycomb-rules-535.dat"); else load_ruleset("honeycomb-rules-534.dat"); - reg3::generate(); origin = tailored_alloc (S7); heptagon& h = *origin; h.s = hsOrigin; @@ -1186,7 +1176,7 @@ EX namespace reg3 { } vector get_vertices(cell* c) override { - return reg3::vertices_only; + return cgi.vertices_only; } }; @@ -1302,7 +1292,7 @@ EX int celldistance(cell *c1, cell *c2) { hyperpoint h = tC0(r->relative_matrix(c1->master, c2->master, C0)); int b = bucketer(h); - if(close_distances.count(b)) return close_distances[b]; + if(cgi.close_distances.count(b)) return cgi.close_distances[b]; if(in_rule()) return clueless_celldistance(c1, c2); @@ -1323,13 +1313,13 @@ EX bool pseudohept(cell *c) { } if(S7 == 8) return h[3] >= .99 || h[3] <= -.99 || abs(h[3]) < .01; - if(loop == 3 && face == 3 && S7 == 4) + if(cgi.loop == 3 && cgi.face == 3 && S7 == 4) return c == m->gamestart(); - if(loop == 4 && face == 3) + if(cgi.loop == 4 && cgi.face == 3) return abs(h[3]) > .9; - if(loop == 3 && face == 4) + if(cgi.loop == 3 && cgi.face == 4) return abs(h[3]) > .9; - if(loop == 5 && face == 3) + if(cgi.loop == 5 && cgi.face == 3) return abs(h[3]) > .99 || abs(h[0]) > .99 || abs(h[1]) > .99 || abs(h[2]) > .99; } // chessboard pattern in 534 @@ -1359,17 +1349,16 @@ EX void generate_cellrotations() { for(int a=0; a 0.01) continue; vector perm(S7); for(int x=0; x= 4 EX cellwalker strafe(cellwalker cw, int j) { - hyperpoint hfront = tC0(adjmoves[cw.spin]); + hyperpoint hfront = tC0(cgi.adjmoves[cw.spin]); transmatrix T = currentmap->adj(cw.at, j); for(int i=0; ic.spin(j)) - if(hdist(hfront, T * tC0(adjmoves[i])) < strafedist + .01) + if(hdist(hfront, T * tC0(cgi.adjmoves[i])) < cgi.strafedist + .01) return cellwalker(cw.at->cmove(j), i); println(hlog, "incorrect strafe"); exit(1); } -EX vector > rels; -EX int xp_order, r_order, rx_order; - -EX transmatrix full_X, full_R, full_P; -geometry_information *for_cgi; - EX int matrix_order(const transmatrix A) { transmatrix T = A; int res = 1; @@ -1507,32 +1490,29 @@ EX int matrix_order(const transmatrix A) { } EX void generate_fulls() { - reg3::generate(); reg3::generate_cellrotations(); auto cons = [&] (int i0, int i1, int i2) { - using reg3::adjmoves; - transmatrix T = build_matrix(adjmoves[ 0]*C0, adjmoves[ 1]*C0, adjmoves[ 2]*C0, C0); - transmatrix U = build_matrix(adjmoves[i0]*C0, adjmoves[i1]*C0, adjmoves[i2]*C0, C0); + transmatrix T = build_matrix(cgi.adjmoves[ 0]*C0, cgi.adjmoves[ 1]*C0, cgi.adjmoves[ 2]*C0, C0); + transmatrix U = build_matrix(cgi.adjmoves[i0]*C0, cgi.adjmoves[i1]*C0, cgi.adjmoves[i2]*C0, C0); return U * inverse(T); }; - full_P = reg3::adjmoves[0]; - full_R = S7 == 8 ? cons(1, 7, 0) : cons(1, 2, 0); - full_X = S7 == 8 ? cons(1, 0, 6) : S7 == 6 ? cons(1, 0, 5) : cons(1, 0, reg3::face); + cgi.full_P = cgi.adjmoves[0]; + cgi.full_R = S7 == 8 ? cons(1, 7, 0) : cons(1, 2, 0); + cgi.full_X = S7 == 8 ? cons(1, 0, 6) : S7 == 6 ? cons(1, 0, 5) : cons(1, 0, cgi.face); - xp_order = matrix_order(full_X * full_P); - r_order = matrix_order(full_R); - rx_order = matrix_order(full_R * full_X); - println(hlog, "orders = ", tie(rx_order, r_order, xp_order)); + cgi.xp_order = matrix_order(cgi.full_X * cgi.full_P); + cgi.r_order = matrix_order(cgi.full_R); + cgi.rx_order = matrix_order(cgi.full_R * cgi.full_X); + println(hlog, "orders = ", tie(cgi.rx_order, cgi.r_order, cgi.xp_order)); } EX void construct_relations() { - if(for_cgi == &cgi) return; - for_cgi = &cgi; + auto& rels = cgi.rels; + if(!rels.empty()) return; rels.clear(); - reg3::generate(); reg3::generate_cellrotations(); reg3::generate_fulls(); vector all; @@ -1542,7 +1522,7 @@ EX void construct_relations() { formulas.push_back(""); all.push_back(Id); - hyperpoint v = reg3::cellshape[0]; + hyperpoint v = cgi.cellshape[0]; auto add = [&] (transmatrix T) { for(int i=0; i