mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-20 15:40:26 +00:00
rulegen:: trace_rootpath changed to beats_exhaustive
This commit is contained in:
parent
045a439d64
commit
81e8a1f113
60
rulegen.cpp
60
rulegen.cpp
@ -814,38 +814,29 @@ EX void ensure_shorter(twalker cw) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void trace_root_path(vector<int>& rp, twalker cw) {
|
EX bool beats_exhaustive(twalker w1, twalker w2) {
|
||||||
auto d = cw.peek()->dist;
|
int iter = 0;
|
||||||
cw += wstep; auto scw = cw;
|
while(true) { iter++;
|
||||||
|
w1 += wstep;
|
||||||
|
w2 += wstep;
|
||||||
|
|
||||||
bool side = (flags & w_parent_side);
|
if(w1.at->dist == 0)
|
||||||
|
return w1.spin > w2.spin;
|
||||||
|
|
||||||
next:
|
be_solid(w1.at);
|
||||||
if(d > 0) {
|
be_solid(w2.at);
|
||||||
ufind(cw);
|
|
||||||
handle_distance_errors();
|
handle_distance_errors();
|
||||||
auto cwd = get_parent_dir(cw);
|
|
||||||
for(int i=0; i<cw.at->type; i++) {
|
auto sw1 = get_parent_dir(w1);
|
||||||
if((!side) && (cw+i) != cwd) continue;
|
auto sw2 = get_parent_dir(w2);
|
||||||
tcell *c1 = cwd.peek();
|
|
||||||
if(!c1) continue;
|
int d1 = w1.to_spin(sw1.spin);
|
||||||
be_solid(c1);
|
int d2 = w2.to_spin(sw2.spin);
|
||||||
handle_distance_errors();
|
if(d1 != d2) return d1 < d2;
|
||||||
if(c1->dist < d) {
|
|
||||||
rp.push_back(i);
|
w1 = sw1;
|
||||||
cw += i;
|
w2 = sw2;
|
||||||
cw += wstep;
|
|
||||||
d--;
|
|
||||||
goto next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(d > 0) {
|
|
||||||
debuglist = {scw};
|
|
||||||
throw rulegen_failure("should not happen [trace]");
|
|
||||||
}
|
|
||||||
rp.push_back(cw.to_spin(0));
|
|
||||||
if(flags & w_parent_reverse) reverse(rp.begin(), rp.end());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EX int parent_updates;
|
EX int parent_updates;
|
||||||
@ -913,17 +904,10 @@ EX twalker get_parent_dir(twalker& cw) {
|
|||||||
|
|
||||||
resolve:
|
resolve:
|
||||||
hard_parents++;
|
hard_parents++;
|
||||||
vector<int> best;
|
bestd = nearer[0];
|
||||||
int bestfor = nearer[0];
|
|
||||||
trace_root_path(best, twalker(c, nearer[0]));
|
|
||||||
|
|
||||||
for(auto ne1: nearer) {
|
for(auto ne1: nearer) if(ne1 != bestd && beats_exhaustive(twalker(c, ne1), twalker(c, bestd)))
|
||||||
vector<int> other;
|
bestd = ne1;
|
||||||
trace_root_path(other, twalker(c, ne1));
|
|
||||||
if(other < best) best = other, bestfor = ne1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bestd = bestfor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bestd == -1) {
|
if(bestd == -1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user