mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-06-26 15:12:48 +00:00
use_exhaustive_distance used in Yendor under same rules
This commit is contained in:
parent
f36fee9faa
commit
d10a6d10b5
10
cell.cpp
10
cell.cpp
@ -974,7 +974,7 @@ EX int heptdistance(cell *c1, cell *c2) {
|
|||||||
else return heptdistance(c1->master, c2->master);
|
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;
|
set<cell*> keep_distances_from;
|
||||||
|
|
||||||
@ -1005,10 +1005,14 @@ EX void erase_saved_distances() {
|
|||||||
perma_distances = isize(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) {
|
EX cell *random_in_distance(cell *c, int d) {
|
||||||
vector<cell*> choices;
|
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);
|
for(auto& p: saved_distances) if(p.first.first == c && p.second == d) choices.push_back(p.first.second);
|
||||||
println(hlog, "choices = ", isize(choices));
|
println(hlog, "choices = ", isize(choices));
|
||||||
if(choices.empty()) return NULL;
|
if(choices.empty()) return NULL;
|
||||||
|
10
racing.cpp
10
racing.cpp
@ -452,12 +452,7 @@ EX void generate_track() {
|
|||||||
makeEmpty(s);
|
makeEmpty(s);
|
||||||
cview(); // needed for some virtualRebases
|
cview(); // needed for some virtualRebases
|
||||||
|
|
||||||
use_exhaustive_distance = false;
|
use_exhaustive_distance = yendor::exhaustive_distance_appropriate();
|
||||||
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;
|
|
||||||
|
|
||||||
if(use_exhaustive_distance)
|
if(use_exhaustive_distance)
|
||||||
permanent_long_distances(s);
|
permanent_long_distances(s);
|
||||||
@ -468,8 +463,7 @@ EX void generate_track() {
|
|||||||
if(WDIM == 3 || weirdhyperbolic) length = max(length - 10 * race_try, 10);
|
if(WDIM == 3 || weirdhyperbolic) length = max(length - 10 * race_try, 10);
|
||||||
|
|
||||||
if(use_exhaustive_distance) {
|
if(use_exhaustive_distance) {
|
||||||
int maxsd = 0;
|
int maxsd = max_saved_distance(s);
|
||||||
for(auto p: saved_distances) maxsd = max(maxsd, p.second);
|
|
||||||
println(hlog, "max length = ", maxsd);
|
println(hlog, "max length = ", maxsd);
|
||||||
length = min(length, maxsd * 5/6);
|
length = min(length, maxsd * 5/6);
|
||||||
}
|
}
|
||||||
|
16
yendor.cpp
16
yendor.cpp
@ -195,6 +195,16 @@ EX namespace yendor {
|
|||||||
return yi[i].found ? ysUnlocked : ysLocked;
|
return yi[i].found ? ysUnlocked : ysLocked;
|
||||||
return ysUntouched;
|
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) {
|
EX bool check(cell *yendor) {
|
||||||
int byi = isize(yi);
|
int byi = isize(yi);
|
||||||
@ -213,9 +223,11 @@ EX namespace yendor {
|
|||||||
|
|
||||||
int odir = 0;
|
int odir = 0;
|
||||||
|
|
||||||
if(euclid && (penrose || archimedean)) {
|
if(exhaustive_distance_appropriate()) {
|
||||||
permanent_long_distances(yendor);
|
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);
|
permanent_long_distances(at);
|
||||||
for(int a=YDIST-2; a>=0; a--) {
|
for(int a=YDIST-2; a>=0; a--) {
|
||||||
nyi.path[a+1] = at;
|
nyi.path[a+1] = at;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user