1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-20 15:40:26 +00:00

celldist now works in the binary tiling as for other geometries (distance from origin, not horocycle index); also types are computed nicely for the origin-based celldist

This commit is contained in:
Zeno Rogue 2018-09-28 16:27:03 +02:00
parent ce390de0d2
commit d0ee141270
5 changed files with 26 additions and 21 deletions

View File

@ -1048,9 +1048,9 @@ int celldist(cell *c) {
return torusmap()->dists[decodeId(c->master)]; return torusmap()->dists[decodeId(c->master)];
if(masterless) if(masterless)
return eudist(decodeId(c->master)); return eudist(decodeId(c->master));
if(sphere) return celldistance(c, currentmap->gamestart()); if(sphere || binarytiling) return celldistance(c, currentmap->gamestart());
if(IRREGULAR) return irr::celldist(c, false); if(IRREGULAR) return irr::celldist(c, false);
if(binarytiling || archimedean || ctof(c)) return c->master->distance; if(archimedean || ctof(c)) return c->master->distance;
if(GOLDBERG) return gp::compute_dist(c, celldist); if(GOLDBERG) return gp::compute_dist(c, celldist);
int dx[MAX_S3]; int dx[MAX_S3];
for(int u=0; u<S3; u++) for(int u=0; u<S3; u++)
@ -1070,7 +1070,7 @@ int celldistAlt(cell *c) {
tie(x,y) = vec_to_pair(decodeId(c->master)); tie(x,y) = vec_to_pair(decodeId(c->master));
return euclidAlt(x, y); return euclidAlt(x, y);
} }
if(binarytiling) return celldist(c) + (specialland == laCamelot && !tactic::on? 30 : 0); if(binarytiling) return c->master->distance + (specialland == laCamelot && !tactic::on? 30 : 0);
if(sphere || quotient) { if(sphere || quotient) {
return celldist(c) - 3; return celldist(c) - 3;
} }

View File

@ -333,7 +333,7 @@ void debugScreen() {
dialog::addSelItem("celldist", its(celldist(mouseover)), 0); dialog::addSelItem("celldist", its(celldist(mouseover)), 0);
dialog::addSelItem("celldistance", its(celldistance(cwt.at, mouseover)), 0); dialog::addSelItem("celldistance", its(celldistance(cwt.at, mouseover)), 0);
dialog::addSelItem("pathdist", its(mouseover->pathdist), 0); dialog::addSelItem("pathdist", its(mouseover->pathdist), 0);
dialog::addSelItem("celldistAlt", mouseover->master->alt ? its(celldistAlt(mouseover)) : "--", 0); dialog::addSelItem("celldistAlt", eubinary ? its(celldistAlt(mouseover)) : "--", 0);
dialog::addSelItem("temporary", its(mouseover->listindex), 0); dialog::addSelItem("temporary", its(mouseover->listindex), 0);
if(GOLDBERG) if(GOLDBERG)
dialog::addSelItem("whirl", gp::disp(gp::get_local_info(mouseover).relative), 0); dialog::addSelItem("whirl", gp::disp(gp::get_local_info(mouseover).relative), 0);

View File

@ -107,7 +107,9 @@ vector<int> expansion_analyzer::gettype(cell *c) {
int d = celldist(c); int d = celldist(c);
for(int i=0; i<c->type; i++) { for(int i=0; i<c->type; i++) {
cell *c1 = c->cmove(i); cell *c1 = c->cmove(i);
res.push_back(subtype(c1) * 4 + celldist(c1) - d); int bonus = 0;
if(binarytiling) bonus += 16 * (celldistAlt(c1) - celldistAlt(c));
res.push_back(bonus + subtype(c1) * 4 + celldist(c1) - d);
} }
canonicize(res); canonicize(res);
return res; return res;
@ -337,7 +339,9 @@ int type_in(expansion_analyzer& ea, cell *c, const cellfunction& f) {
int d = f(c); int d = f(c);
for(int i=0; i<c->type; i++) { for(int i=0; i<c->type; i++) {
cell *c1 = c->cmove(i); cell *c1 = c->cmove(i);
res.push_back(subtype(c1) * 4 + f(c1) - d); int bonus = 0;
if(binarytiling) bonus += 16 * (celldistAlt(c1) - celldistAlt(c));
res.push_back(bonus + subtype(c1) * 4 + f(c1) - d);
} }
canonicize(res); canonicize(res);
@ -660,11 +664,7 @@ void expansion_analyzer::view_distances_dialog() {
dialog::addBreak(100 * scrolltime / scrollspeed); dialog::addBreak(100 * scrolltime / scrollspeed);
if(binarytiling){ if(sizes_known() || binarytiling) {
dialog::addBreak(200);
dialog::addInfo("a(d) ~ 2ᵈ");
}
else if(sizes_known()) {
if(euclid) { if(euclid) {
dialog::addBreak(200); dialog::addBreak(200);
dialog::addInfo("a(d) = " + its(get_descendants(10).approx_int() - get_descendants(9).approx_int()) + "d", forecolor); dialog::addInfo("a(d) = " + its(get_descendants(10).approx_int() - get_descendants(9).approx_int()) + "d", forecolor);
@ -843,11 +843,16 @@ void set_sibling_limit() {
sibling_limit = 2 * p.first + p.second; sibling_limit = 2 * p.first + p.second;
} }
int celldist0(cell *c) {
if(binarytiling) return celldistAlt(c);
else return celldist(c);
}
bool in_segment(cell *left, cell *mid, cell *right) { bool in_segment(cell *left, cell *mid, cell *right) {
while(true) { while(true) {
if(mid == left) return true; if(mid == left) return true;
if(left == right) return false; if(left == right) return false;
left = ts::right_of(left, celldist); left = ts::right_of(left, celldist0);
} }
} }
@ -857,14 +862,14 @@ int sibling_distance(cell *a, cell *b, int limit) {
if(a == b) return counting; if(a == b) return counting;
if(limit == 0) return INF; if(limit == 0) return INF;
counting++; limit--; counting++; limit--;
a = ts::right_of(a, celldist); a = ts::right_of(a, celldist0);
} }
} }
int hyperbolic_celldistance(cell *c1, cell *c2) { int hyperbolic_celldistance(cell *c1, cell *c2) {
int found_distance = INF; int found_distance = INF;
int d = 0, d1 = celldist(c1), d2 = celldist(c2), sl_used = 0; int d = 0, d1 = celldist0(c1), d2 = celldist0(c2), sl_used = 0;
cell *cl1=c1, *cr1=c1, *cl2=c2, *cr2=c2; cell *cl1=c1, *cr1=c1, *cl2=c2, *cr2=c2;
while(true) { while(true) {
@ -917,13 +922,13 @@ int hyperbolic_celldistance(cell *c1, cell *c2) {
} }
if(d1 >= d2) { if(d1 >= d2) {
cl1 = ts::left_parent(cl1, celldist); cl1 = ts::left_parent(cl1, celldist0);
cr1 = ts::right_parent(cr1, celldist); cr1 = ts::right_parent(cr1, celldist0);
d++; d1--; d++; d1--;
} }
if(d1 < d2) { if(d1 < d2) {
cl2 = ts::left_parent(cl2, celldist); cl2 = ts::left_parent(cl2, celldist0);
cr2 = ts::right_parent(cr2, celldist); cr2 = ts::right_parent(cr2, celldist0);
d++; d2--; d++; d2--;
} }
} }

View File

@ -262,7 +262,7 @@ void virtualRebase(cell*& base, T& at, bool tohex, const U& check) {
transmatrix bestV; transmatrix bestV;
for(int d=0; d<S7; d++) { if(!binarytiling) for(int d=0; d<S7; d++) {
heptspin hs(h, d, false); heptspin hs(h, d, false);
heptspin hs2 = hs + wstep; heptspin hs2 = hs + wstep;
transmatrix V2 = spin(-hs2.spin*2*M_PI/S7) * invheptmove[d]; transmatrix V2 = spin(-hs2.spin*2*M_PI/S7) * invheptmove[d];
@ -294,7 +294,7 @@ void virtualRebase(cell*& base, T& at, bool tohex, const U& check) {
at = bestV * at; at = bestV * at;
} }
else at = master_relative(base, true) * at; else at = master_relative(base, true) * at;
if(tohex && GOLDBERG) { if(binarytiling || (tohex && (GOLDBERG || IRREGULAR))) {
while(true) { while(true) {
newbase = NULL; newbase = NULL;
forCellCM(c2, base) { forCellCM(c2, base) {

View File

@ -218,7 +218,7 @@ namespace yendor {
// make it challenging // make it challenging
vector<int> ds; vector<int> ds;
for(int d=0; d<ycw.at->type; d++) { for(int d=0; d<ycw.at->type; d++) {
if(celldist((ycw+d).cpeek()) < celldist(ycw.at)) if(celldistAlt((ycw+d).cpeek()) < celldistAlt(ycw.at))
ds.push_back(d); ds.push_back(d);
} }
if(isize(ds)) ycw += ds[hrand(isize(ds))]; if(isize(ds)) ycw += ds[hrand(isize(ds))];