1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-02-22 14:00:13 +00:00

use_exhaustive_distance used in Yendor under same rules

This commit is contained in:
Zeno Rogue 2019-11-15 02:51:25 +01:00
parent f36fee9faa
commit d10a6d10b5
3 changed files with 23 additions and 13 deletions

View File

@ -974,7 +974,7 @@ EX int heptdistance(cell *c1, cell *c2) {
else return heptdistance(c1->master, c2->master);
}
EX map<pair<cell*, cell*>, int> saved_distances;
map<pair<cell*, cell*>, int> saved_distances;
set<cell*> keep_distances_from;
@ -1005,10 +1005,14 @@ EX void erase_saved_distances() {
perma_distances = isize(saved_distances);
}
EX int max_saved_distance(cell *c) {
int maxsd = 0;
for(auto& p: saved_distances) if(p.first.first == c) maxsd = max(maxsd, p.second);
return maxsd;
}
EX cell *random_in_distance(cell *c, int d) {
vector<cell*> choices;
for(auto& p: saved_distances) println(hlog, p);
for(auto& p: saved_distances) if(p.first.first == c && p.second == d) choices.push_back(p.first.second);
println(hlog, "choices = ", isize(choices));
if(choices.empty()) return NULL;

View File

@ -452,12 +452,7 @@ EX void generate_track() {
makeEmpty(s);
cview(); // needed for some virtualRebases
use_exhaustive_distance = false;
if(euclid && (penrose || archimedean || quotient)) use_exhaustive_distance = true;
if(nil && quotient) use_exhaustive_distance = true;
if(asonov::in() && asonov::period_xy && asonov::period_xy <= 256) use_exhaustive_distance = true;
if(bounded) use_exhaustive_distance = true;
use_exhaustive_distance = yendor::exhaustive_distance_appropriate();
if(use_exhaustive_distance)
permanent_long_distances(s);
@ -468,8 +463,7 @@ EX void generate_track() {
if(WDIM == 3 || weirdhyperbolic) length = max(length - 10 * race_try, 10);
if(use_exhaustive_distance) {
int maxsd = 0;
for(auto p: saved_distances) maxsd = max(maxsd, p.second);
int maxsd = max_saved_distance(s);
println(hlog, "max length = ", maxsd);
length = min(length, maxsd * 5/6);
}

View File

@ -195,6 +195,16 @@ EX namespace yendor {
return yi[i].found ? ysUnlocked : ysLocked;
return ysUntouched;
}
EX bool exhaustive_distance_appropriate() {
if(euclid && (penrose || archimedean || quotient)) return true;
if(nil && quotient) return true;
if(asonov::in() && asonov::period_xy && asonov::period_xy <= 256) return true;
if(bounded) return true;
return false;
}
EX bool check(cell *yendor) {
int byi = isize(yi);
@ -213,9 +223,11 @@ EX namespace yendor {
int odir = 0;
if(euclid && (penrose || archimedean)) {
if(exhaustive_distance_appropriate()) {
permanent_long_distances(yendor);
auto at = random_in_distance(yendor, YDIST-1);
int dist = max_saved_distance(yendor);
dist = min(dist, YDIST-1);
auto at = random_in_distance(yendor, dist);
permanent_long_distances(at);
for(int a=YDIST-2; a>=0; a--) {
nyi.path[a+1] = at;