hybrid:: celldistance

This commit is contained in:
Zeno Rogue 2019-11-30 13:27:44 +01:00
parent 77c1e95701
commit 46892a35c4
2 changed files with 26 additions and 9 deletions

View File

@ -441,11 +441,8 @@ EX int compdist(int dx[]) {
EX int celldist(cell *c) {
if(experimental) return 0;
if(hybri) {
auto w = hybrid::get_where(c);
if(sl2) w.second = 0;
return PIU ( celldist(w.first) + abs(w.second) );
}
if(hybri)
return hybrid::celldistance(c, currentmap->gamestart());
if(nil && !quotient) return DISTANCE_UNKNOWN;
if(euclid) 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) {
if(prod) {
auto w1 = hybrid::get_where(c1), w2 = hybrid::get_where(c2);
return PIU ( celldistance(w1.first, w2.first) + abs(w1.second - w2.second) );
}
if(hybri) return hybrid::celldistance(c1, c2);
#if CAP_FIELD
if(geometry == gFieldQuotient && !GOLDBERG)

View File

@ -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 namespace product {