mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-20 23:50:27 +00:00
randomdir option for generate_random_path
This commit is contained in:
parent
ebfe0b6f48
commit
0f2f435534
@ -825,6 +825,7 @@ EX bool exhaustive_distance_appropriate() {
|
|||||||
#if HDR
|
#if HDR
|
||||||
struct pathgen {
|
struct pathgen {
|
||||||
cellwalker start;
|
cellwalker start;
|
||||||
|
cellwalker last;
|
||||||
vector<cell*> path;
|
vector<cell*> path;
|
||||||
bignum full_id_0;
|
bignum full_id_0;
|
||||||
int last_id;
|
int last_id;
|
||||||
@ -833,10 +834,10 @@ struct pathgen {
|
|||||||
|
|
||||||
EX pathgen generate_random_path_randomdir(cellwalker start, int length, bool for_yendor) {
|
EX pathgen generate_random_path_randomdir(cellwalker start, int length, bool for_yendor) {
|
||||||
start.spin = hrand(start.at->type);
|
start.spin = hrand(start.at->type);
|
||||||
return generate_random_path(start, length, for_yendor);
|
return generate_random_path(start, length, for_yendor, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
EX pathgen generate_random_path(cellwalker start, int length, bool for_yendor) {
|
EX pathgen generate_random_path(cellwalker start, int length, bool for_yendor, bool randomdir) {
|
||||||
pathgen p;
|
pathgen p;
|
||||||
p.start = start;
|
p.start = start;
|
||||||
p.path.resize(length+1);
|
p.path.resize(length+1);
|
||||||
@ -858,11 +859,13 @@ EX pathgen generate_random_path(cellwalker start, int length, bool for_yendor) {
|
|||||||
if(isize(prev)) at = prev[hrand(isize(prev))];
|
if(isize(prev)) at = prev[hrand(isize(prev))];
|
||||||
}
|
}
|
||||||
p.path[0] = start.at;
|
p.path[0] = start.at;
|
||||||
|
p.last = p.path.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(hybri) {
|
else if(hybri) {
|
||||||
/* I am lazy */
|
/* I am lazy */
|
||||||
for(int i=1; i<=length; i++) p.path[i] = p.path[i-1]->cmove(p.path[i-1]->type-1);
|
for(int i=1; i<=length; i++) p.path[i] = p.path[i-1]->cmove(p.path[i-1]->type-1);
|
||||||
|
p.last = p.path.back();
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
@ -871,7 +874,6 @@ EX pathgen generate_random_path(cellwalker start, int length, bool for_yendor) {
|
|||||||
bool onlychild = true;
|
bool onlychild = true;
|
||||||
|
|
||||||
cellwalker ycw = start;
|
cellwalker ycw = start;
|
||||||
ycw--; if(S3 == 3) ycw--;
|
|
||||||
if(for_yendor) setdist(p.path[0], 7, NULL);
|
if(for_yendor) setdist(p.path[0], 7, NULL);
|
||||||
|
|
||||||
for(int i=0; i<length; i++) {
|
for(int i=0; i<length; i++) {
|
||||||
@ -900,9 +902,12 @@ EX pathgen generate_random_path(cellwalker start, int length, bool for_yendor) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if(trees_known()) {
|
else if(trees_known()) {
|
||||||
|
auto sdist = [start] (cell *c) { return celldistance(start.at, c); };
|
||||||
if(i == 0) {
|
if(i == 0) {
|
||||||
t = type_in(expansion, start.at, [start] (cell *c) { return celldistance(start.at, c); });
|
t = type_in(expansion, randomdir ? start.at : start.cpeek(), sdist);
|
||||||
bignum b = expansion.get_descendants(length, t);
|
ycw--;
|
||||||
|
if(valence() == 3) ycw--;
|
||||||
|
bignum b = expansion.get_descendants(randomdir ? length : length-1, t);
|
||||||
p.full_id_0 = full_id = hrand(b);
|
p.full_id_0 = full_id = hrand(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -922,8 +927,7 @@ EX pathgen generate_random_path(cellwalker start, int length, bool for_yendor) {
|
|||||||
|
|
||||||
for(int tch: expansion.children[t]) {
|
for(int tch: expansion.children[t]) {
|
||||||
ycw++;
|
ycw++;
|
||||||
if(i == 1)
|
if(i < 2) tch = type_in(expansion, ycw.cpeek(), sdist);
|
||||||
tch = type_in(expansion, ycw.cpeek(), [start] (cell *c) { return celldistance(start.at, c); });
|
|
||||||
auto& sub_id = expansion.get_descendants(length-1-i, tch);
|
auto& sub_id = expansion.get_descendants(length-1-i, tch);
|
||||||
if(full_id < sub_id) { t = tch; break; }
|
if(full_id < sub_id) { t = tch; break; }
|
||||||
|
|
||||||
@ -972,6 +976,7 @@ EX pathgen generate_random_path(cellwalker start, int length, bool for_yendor) {
|
|||||||
ycw += wstep;
|
ycw += wstep;
|
||||||
p.path[i+1] = ycw.at;
|
p.path[i+1] = ycw.at;
|
||||||
}
|
}
|
||||||
|
p.last = ycw + rev;
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user