1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-06-15 01:39:57 +00:00

rulegen3:: renaming/refactoring

This commit is contained in:
Zeno Rogue 2022-08-17 17:58:49 +02:00
parent cc258f1f31
commit 14f1da6de4
2 changed files with 49 additions and 43 deletions

View File

@ -96,7 +96,7 @@ static const flagtype w_r3_no_road_shortcuts = Flag(36); /*< consider all errors
/** these control the output */
EX flagtype rdebug_flags;
EX int honeycomb_value = 1; /* how far to build local for honeycombs */
EX int r3_neighborhood_decision = 1; /* how far to build local for honeycombs */
EX flagtype flags = 0;
@ -1366,8 +1366,8 @@ EX void id_at_spin(twalker cw, vector<twalker>& sprawl, vector<analyzer_state*>&
a = alloc_analyzer();
}
states.push_back(a);
if(WDIM == 3 && honeycomb_value) {
auto& ae = check_all_edges(cw, a, isize(sprawl));
if(WDIM == 3 && r3_neighborhood_decision) {
auto& ae = get_decision_neighborhood(cw);
int id = isize(sprawl);
if(id < isize(ae)) {
a->id = ae[id].first;
@ -2505,7 +2505,7 @@ auto hooks = addHook(hooks_configfile, 100, [] {
param_i(max_ignore_level_post, "max_ignore_level_post");
param_i(max_ignore_time_pre, "max_ignore_time_pre");
param_i(max_ignore_time_post, "max_ignore_time_post");
param_i(honeycomb_value, "honeycomb_value");
param_i(r3_neighborhood_decision, "r3_neighborhood_decision");
});
EX void parse_treestate(arb::arbi_tiling& c, exp_parser& ep) {

View File

@ -145,11 +145,13 @@ EX int get_roadsign(twalker what) {
return roadsign_id[result] = next_roadsign_id--;
}
map<pair<int, int>, vector<pair<int, int>> > all_edges;
#if HDR
using neighborhood = vector<pair<int, int>>;
#endif
EX vector<pair<int, int>>& check_all_edges(twalker cw, analyzer_state* a, int id) {
auto& ae = all_edges[{cw.at->id, cw.spin}];
if(ae.empty()) {
map<pair<int, int>, neighborhood> all_edges;
EX void build_neighborhood(twalker cw, neighborhood& ae, flagtype dec) {
set<tcell*> seen;
vector<pair<twalker, transmatrix> > visited;
vector<pair<int, int>> ae1;
@ -168,7 +170,7 @@ EX vector<pair<int, int>>& check_all_edges(twalker cw, analyzer_state* a, int id
for(auto w: rotated)
if(sqhypot_d(MDIM, v-w) < 1e-6)
common++;
if(honeycomb_value >= 2) {
if(dec & 2) {
if(common < 1) { ae1.emplace_back(id, dir); return; }
}
else {
@ -184,9 +186,13 @@ EX vector<pair<int, int>>& check_all_edges(twalker cw, analyzer_state* a, int id
visit(tw + j + wstep, visited[i].second * currentmap->adj(tcell_to_cell[tw.at], (tw+j).spin), i, j);
}
}
if(honeycomb_value >= 3) for(auto p: ae1) ae.push_back(p);
if(dec & 4) for(auto p: ae1) ae.push_back(p);
println(hlog, "for ", tie(cw.at->id, cw.spin), " generated all_edges structure: ", ae, " of size ", isize(ae));
}
EX neighborhood& get_decision_neighborhood(twalker cw) {
auto& ae = all_edges[{cw.at->id, cw.spin}];
if(ae.empty()) build_neighborhood(cw, ae, r3_neighborhood_decision);
return ae;
}