1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-24 09:00:34 +00:00

rulegen:: fix weird errors

This commit is contained in:
Zeno Rogue 2021-08-22 14:31:13 +02:00
parent d361d2bf61
commit 359227c84a

View File

@ -1262,8 +1262,15 @@ tsinfo get_tsinfo(twalker tw) {
return {co.second, spin}; return {co.second, spin};
} }
int get_rule(tsinfo s) { int get_rule(const twalker tw, tsinfo s) {
return treestates[s.first].rules[s.second];
auto& r = treestates[s.first].rules;
if(r.empty()) {
important.push_back(tw.at);
throw rulegen_retry("unknown rule in get_rule");
}
return r[s.second];
} }
set<vector<tsinfo> > verified_branches; set<vector<tsinfo> > verified_branches;
@ -1338,8 +1345,8 @@ void examine_branch(int id, int left, int right) {
auto tsl = get_tsinfo(wl); auto tsl = get_tsinfo(wl);
auto tsr = get_tsinfo(wr); auto tsr = get_tsinfo(wr);
auto rl = get_rule(tsl); auto rl = get_rule(wl, tsl);
auto rr = get_rule(tsr); auto rr = get_rule(wr, tsr);
// println(hlog, "wl = ", wl, " -> ", wl+wstep, " R", rl, " wr = ", wr, " -> ", wr+wstep, " R", rr, " lstack = ", lstack, " rstack = ", rstack); // println(hlog, "wl = ", wl, " -> ", wl+wstep, " R", rl, " wr = ", wr, " -> ", wr+wstep, " R", rr, " lstack = ", lstack, " rstack = ", rstack);
@ -1407,7 +1414,7 @@ void find_single_live_branch(twalker at) {
rules_iteration_for(at.at); rules_iteration_for(at.at);
int id = get_code(at.at).second; int id = get_code(at.at).second;
int t = at.at->type; int t = at.at->type;
auto& r = treestates[id].rules; auto r = treestates[id].rules; /* no & because may move */
int q = 0; int q = 0;
if(r.empty()) { important.push_back(at.at); throw rulegen_retry("no giver in find_single_live_branch"); } if(r.empty()) { important.push_back(at.at); throw rulegen_retry("no giver in find_single_live_branch"); }
for(int i=0; i<t; i++) if(r[i] >= 0) { for(int i=0; i<t; i++) if(r[i] >= 0) {
@ -1535,6 +1542,10 @@ EX void rules_iteration() {
} }
if(treestates[id].is_root) examine_branch(id, last_live_branch, first_live_branch); if(treestates[id].is_root) examine_branch(id, last_live_branch, first_live_branch);
} }
for(int id=0; id<isize(treestates); id++) if(!treestates[id].giver.at) {
important.push_back(treestates[id].where_seen);
}
handle_distance_errors(); handle_distance_errors();
if(isize(important) != N) if(isize(important) != N)