From e466ed8e2258022d1351497fb5bd560ba9db5127 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 26 Dec 2021 17:31:42 +0100 Subject: [PATCH] Revert "rulegen:: trace_rootpath changed to beats_exhaustive" This reverts commit 81e8a1f113f82f5cf4998960f3ffec68b736c490. --- rulegen.cpp | 60 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/rulegen.cpp b/rulegen.cpp index f1e645b4..5e1d6534 100644 --- a/rulegen.cpp +++ b/rulegen.cpp @@ -814,29 +814,38 @@ EX void ensure_shorter(twalker cw) { } } -EX bool beats_exhaustive(twalker w1, twalker w2) { - int iter = 0; - while(true) { iter++; - w1 += wstep; - w2 += wstep; +void trace_root_path(vector& rp, twalker cw) { + auto d = cw.peek()->dist; + cw += wstep; auto scw = cw; - if(w1.at->dist == 0) - return w1.spin > w2.spin; + bool side = (flags & w_parent_side); - be_solid(w1.at); - be_solid(w2.at); + next: + if(d > 0) { + ufind(cw); handle_distance_errors(); - - auto sw1 = get_parent_dir(w1); - auto sw2 = get_parent_dir(w2); - - int d1 = w1.to_spin(sw1.spin); - int d2 = w2.to_spin(sw2.spin); - if(d1 != d2) return d1 < d2; - - w1 = sw1; - w2 = sw2; + auto cwd = get_parent_dir(cw); + for(int i=0; itype; i++) { + if((!side) && (cw+i) != cwd) continue; + tcell *c1 = cwd.peek(); + if(!c1) continue; + be_solid(c1); + handle_distance_errors(); + if(c1->dist < d) { + rp.push_back(i); + cw += i; + 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; @@ -904,10 +913,17 @@ EX twalker get_parent_dir(twalker& cw) { resolve: hard_parents++; - bestd = nearer[0]; + vector best; + int bestfor = nearer[0]; + trace_root_path(best, twalker(c, nearer[0])); - for(auto ne1: nearer) if(ne1 != bestd && beats_exhaustive(twalker(c, ne1), twalker(c, bestd))) - bestd = ne1; + for(auto ne1: nearer) { + vector other; + trace_root_path(other, twalker(c, ne1)); + if(other < best) best = other, bestfor = ne1; + } + + bestd = bestfor; } if(bestd == -1) {