From c7f74cc745a76ee6564fd3c3eded740de73ba7cf Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 3 Dec 2018 21:54:36 +0100 Subject: [PATCH] Added the constant PERIOD (=2*FULLSTEP) instead of 4, also commented on the constants --- crystal.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/crystal.cpp b/crystal.cpp index e7168aab..5b80b4d3 100644 --- a/crystal.cpp +++ b/crystal.cpp @@ -6,6 +6,15 @@ namespace hr { namespace crystal { +// Crystal can be bitruncated either by changing variation to bitruncated. +// In case of the 4D Crystal, the standard HyperRogue bitruncation becomes +// confused by having both the original and new vertices of degree 8. +// Hence Crystal implements its own bitruncation, which is selected/checked +// by setting ginf[gCrystal].vertex to 3. Additionally, this lets us double +// bitruncate. + +// Function pure() checks for both kinds of bitruncation (or any other variations). + bool pure() { return PURE && ginf[gCrystal].vertex == 4; } @@ -39,9 +48,16 @@ void resize2(vector>& v, int a, int b, int z) { for(auto& w: v) w.resize(b, z); } +// in the "pure" form, the adjacent vertices are internaly spaced by 2... const int FULLSTEP = 2; + +// ... to make space for the additional vertices which are added in the bitruncated version const int HALFSTEP = 1; +// with variations, the connections of the vertex at coordinate v+FULLSTEP mirror the connections +// of the vertex at coordinate v. Therefore, the period of our construction is actually 2*FULLSTEP. +const int PERIOD = 2 * FULLSTEP; + struct crystal_structure { int dir; int dim; @@ -526,9 +542,9 @@ int precise_distance(cell *c1, cell *c2) { auto h = m->get_coord(c3) - co1; ld dot = (h|mul); - if(dot > mmax + 2.5) continue; + if(dot > mmax + PERIOD/2 + .1) continue; - for(int k=0; kcs.dim; k++) if(abs(h[k] - dot * mul[k]) > 4.1) goto next3; + for(int k=0; kcs.dim; k++) if(abs(h[k] - dot * mul[k]) > PERIOD + .1) goto next3; cl.add(c3); next3: ; } @@ -584,7 +600,7 @@ int dist_relative(cell *c) { coord hrmap_crystal::long_representant(cell *c) { auto& coordid = east.coordid; - auto co = roundcoord(get_coord(c) * Modval/4); + auto co = roundcoord(get_coord(c) * Modval/PERIOD); for(int s=0; sgamestart()); - ld rad2 = pow(roundTableRadius(NULL) / m->camelot_mul / 4, 2) + 1e-4; + ld rad2 = pow(roundTableRadius(NULL) / m->camelot_mul / PERIOD, 2) + 1e-4; for(int i=0; i maxcoord) maxcoord = co[i]; } static const ld eps = 1e-4; - if(mincoord >= 0-eps && maxcoord < 4-eps) { + if(mincoord >= 0-eps && maxcoord < PERIOD-eps) { ld my_rad2 = rad2; - auto cshift = (co - m->camelot_coord) / 4; + auto cshift = (co - m->camelot_coord) / PERIOD; auto sd = &shift_data_zero; for(int i=0; ics.dim; i++) { if(i == m->cs.dim-1 && (m->cs.dir&1)) {