mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-06-16 02:09:59 +00:00
hybrid:: celldistance
This commit is contained in:
parent
77c1e95701
commit
46892a35c4
12
cell.cpp
12
cell.cpp
|
@ -441,11 +441,8 @@ EX int compdist(int dx[]) {
|
||||||
|
|
||||||
EX int celldist(cell *c) {
|
EX int celldist(cell *c) {
|
||||||
if(experimental) return 0;
|
if(experimental) return 0;
|
||||||
if(hybri) {
|
if(hybri)
|
||||||
auto w = hybrid::get_where(c);
|
return hybrid::celldistance(c, currentmap->gamestart());
|
||||||
if(sl2) w.second = 0;
|
|
||||||
return PIU ( celldist(w.first) + abs(w.second) );
|
|
||||||
}
|
|
||||||
if(nil && !quotient) return DISTANCE_UNKNOWN;
|
if(nil && !quotient) return DISTANCE_UNKNOWN;
|
||||||
if(euclid) return celldistance(currentmap->gamestart(), c);
|
if(euclid) return celldistance(currentmap->gamestart(), c);
|
||||||
if(sphere || binarytiling || WDIM == 3 || cryst || solnih || penrose) return celldistance(currentmap->gamestart(), c);
|
if(sphere || binarytiling || WDIM == 3 || cryst || solnih || penrose) return celldistance(currentmap->gamestart(), c);
|
||||||
|
@ -983,10 +980,7 @@ EX cell *random_in_distance(cell *c, int d) {
|
||||||
|
|
||||||
EX int celldistance(cell *c1, cell *c2) {
|
EX int celldistance(cell *c1, cell *c2) {
|
||||||
|
|
||||||
if(prod) {
|
if(hybri) return hybrid::celldistance(c1, c2);
|
||||||
auto w1 = hybrid::get_where(c1), w2 = hybrid::get_where(c2);
|
|
||||||
return PIU ( celldistance(w1.first, w2.first) + abs(w1.second - w2.second) );
|
|
||||||
}
|
|
||||||
|
|
||||||
#if CAP_FIELD
|
#if CAP_FIELD
|
||||||
if(geometry == gFieldQuotient && !GOLDBERG)
|
if(geometry == gFieldQuotient && !GOLDBERG)
|
||||||
|
|
|
@ -1238,6 +1238,29 @@ EX namespace hybrid {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EX int celldistance(cell *c1, cell *c2) {
|
||||||
|
if(cgi.steps == 0) {
|
||||||
|
auto w1 = hybrid::get_where(c1), w2 = hybrid::get_where(c2);
|
||||||
|
return PIU (hr::celldistance(w1.first, w2.first)) + abs(w1.second - w2.second);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int s = 0;
|
||||||
|
int a = 999999, b = -999999;
|
||||||
|
auto c = c1;
|
||||||
|
do {
|
||||||
|
auto w1 = hybrid::get_where(c), w2 = hybrid::get_where(c2);
|
||||||
|
if(w1.second == w2.second) {
|
||||||
|
int d = PIU(hr::celldistance(w1.first, w2.first));
|
||||||
|
a = min(s+d, a);
|
||||||
|
b = max(s-d, a);
|
||||||
|
}
|
||||||
|
c = c->cmove(c1->type-1); s++;
|
||||||
|
}
|
||||||
|
while(c != c1);
|
||||||
|
return min(a, s-b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EX }
|
EX }
|
||||||
|
|
||||||
EX namespace product {
|
EX namespace product {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user