1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-27 14:37:16 +00:00

gp:: adjm to fix the confusion in quotient spaces

This commit is contained in:
Zeno Rogue 2019-11-27 00:43:30 +01:00
parent 6bb3a076da
commit a1fbfb2946
4 changed files with 40 additions and 1 deletions

View File

@ -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);

View File

@ -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; i<h1->type; 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);

View File

@ -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<pair<cell*, int>, 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);

View File

@ -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);