mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-04-09 20:26:45 +00:00
gp:: distance calculation
This commit is contained in:
parent
aaf0a949c3
commit
f94c85a4fa
38
goldberg.cpp
38
goldberg.cpp
@ -791,7 +791,7 @@ namespace hr { namespace gp {
|
||||
sp++;
|
||||
goto again;
|
||||
}
|
||||
if(sp>3) sp -= 6;
|
||||
if(sp>SG3) sp -= SG6;
|
||||
li.last_dir = fix7(li.last_dir - sp);
|
||||
}
|
||||
|
||||
@ -814,8 +814,35 @@ namespace hr { namespace gp {
|
||||
if(c0-cc == d0-dmain && c1-cc == d1-dmain)
|
||||
found = true, centerloc = c;
|
||||
}
|
||||
if(!found && !quotient)
|
||||
if(!found && !quotient) {
|
||||
Xprintf("Warning: centerloc not found: %d,%d,%d\n", dmain, d0, d1);
|
||||
}
|
||||
center_locs[rel] = centerloc;
|
||||
}
|
||||
|
||||
return dmain + length(centerloc-at) - length(centerloc);
|
||||
}
|
||||
|
||||
int solve_quad(int dmain, int d0, int d1, int dx, loc at) {
|
||||
loc centerloc(0, 0);
|
||||
auto rel = make_pair(d0-dmain, (d1-dmain) + 1000 * (dx-dmain) + 1000000);
|
||||
if(center_locs.count(rel))
|
||||
centerloc = center_locs[rel];
|
||||
else {
|
||||
bool found = false;
|
||||
for(int y=-20; y<=20; y++)
|
||||
for(int x=-20; x<=20; x++) {
|
||||
loc c(x, y);
|
||||
int cc = length(c);
|
||||
int c0 = length(c - param);
|
||||
int c1 = length(c - param*loc(0,1));
|
||||
int c2 = length(c - param*loc(1,1));
|
||||
if(c0-cc == d0-dmain && c1-cc == d1-dmain && c2-cc == dx-dmain)
|
||||
found = true, centerloc = c;
|
||||
}
|
||||
if(!found && !quotient) {
|
||||
Xprintf("Warning: centerloc not found: %d,%d,%d,%d\n", dmain, d0, d1, dx);
|
||||
}
|
||||
center_locs[rel] = centerloc;
|
||||
}
|
||||
|
||||
@ -847,6 +874,13 @@ namespace hr { namespace gp {
|
||||
auto d0 = master_function(createStep(cm->master, i)->c7);
|
||||
auto d1 = master_function(createStep(cm->master, fixdir(i+1, cm))->c7);
|
||||
|
||||
if(S3 == 4) {
|
||||
heptspin hs(cm->master, i);
|
||||
hs += wstep; hs+=-1; hs += wstep;
|
||||
auto d2 = master_function(hs.h->c7);
|
||||
return solve_quad(dmain, d0, d1, d2, at);
|
||||
}
|
||||
|
||||
return solve_triangle(dmain, d0, d1, at);
|
||||
}
|
||||
|
||||
|
26
heptagon.cpp
26
heptagon.cpp
@ -122,6 +122,29 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix
|
||||
);
|
||||
}
|
||||
else if(parent->s == hsOrigin) h->distance = parent->distance + gp::dist_2();
|
||||
else if(S3 == 4 && gp::on && h->spin(0) == S7-2 && h->move[0]->spin(0) >= S7-2 && h->move[0]->move[0]->s != hsOrigin) {
|
||||
heptspin hs(h, 0);
|
||||
hs += wstep;
|
||||
int d1 = hs.h->distance;
|
||||
hs += 1; hs += wstep;
|
||||
int dm = hs.h->distance;
|
||||
hs += -1; hs += wstep;
|
||||
int d0 = hs.h->distance;
|
||||
h->distance = gp::solve_triangle(dm, d0, d1, gp::operator* (gp::param, gp::loc(-1,1)));
|
||||
}
|
||||
else if(S3 == 4 && gp::on && h->spin(0) == S7-1 && among(h->move[0]->spin(0), S7-2, S7-3) && h->move[0]->move[0]->s != hsOrigin) {
|
||||
heptspin hs(h, 0);
|
||||
hs += wstep;
|
||||
int d0 = hs.h->distance;
|
||||
hs += 1; hs += wstep;
|
||||
int dm = hs.h->distance;
|
||||
hs += 1; hs += wstep;
|
||||
int d1 = hs.h->distance;
|
||||
h->distance = gp::solve_triangle(dm, d0, d1, gp::operator* (gp::param, gp::loc(1,1)));
|
||||
}
|
||||
else if(S3 == 4 && gp::on && h->spin(0) >= 2 && h->spin(0) <= S7-2) {
|
||||
h->distance = parent->distance + gp::dist_2();
|
||||
}
|
||||
else if(h->spin(0) == S7-2) {
|
||||
if(!gp::on)
|
||||
h->distance = parent->distance + gp::dist_1();
|
||||
@ -143,6 +166,9 @@ heptagon *buildHeptagon(heptagon *parent, int d, hstate s, int pard = 0, int fix
|
||||
h->distance = gp::solve_triangle(dm, d0, d1, gp::operator* (gp::param, gp::loc(1,1)));
|
||||
}
|
||||
}
|
||||
else if(h->spin(0) == S7-1 && S3 == 4 && gp::on) {
|
||||
h->distance = parent->distance + gp::dist_1();
|
||||
}
|
||||
else h->distance = parent->distance + gp::dist_2();
|
||||
}
|
||||
else {
|
||||
|
6
hyper.h
6
hyper.h
@ -3653,4 +3653,10 @@ extern hpcshape shDisk, shTriangle, shHeptaMarker, shSnowball, shDiskT, shDiskS,
|
||||
|
||||
extern std::mt19937 hrngen;
|
||||
|
||||
heptspin& operator += (heptspin& hs, int spin);
|
||||
heptspin operator + (const heptspin& hs, wstep_t);
|
||||
heptspin operator + (heptspin h, int spin);
|
||||
heptspin operator - (heptspin h, int spin);
|
||||
heptspin& operator += (heptspin& h, wstep_t);
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user