mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-03-27 22:07:03 +00:00
refactored link_alt
This commit is contained in:
parent
6540c9968c
commit
1c31a987a8
10
bigstuff.cpp
10
bigstuff.cpp
@ -292,21 +292,19 @@ EX heptagon *createAlternateMap(cell *c, int rad, hstate firststate, int special
|
||||
if(!polarb50(c)) return NULL;
|
||||
}
|
||||
|
||||
bf += rev;
|
||||
|
||||
heptagon *alt = init_heptagon(h->type);
|
||||
allmaps.push_back(newAltMap(alt));
|
||||
//printf("new alt {%p}\n", hr::voidp(alt));
|
||||
alt->s = firststate;
|
||||
if(hybri) alt->fieldval = hybrid::get_where(centerover).second;
|
||||
alt->alt = alt;
|
||||
#if MAXMDIM >= 4
|
||||
if(reg3::in_rule()) {
|
||||
reg3::link_structures(h, alt, firststate);
|
||||
if(alt->fiftyval == -1) return nullptr; /* unlinked */
|
||||
if(!currentmap->link_alt(h, alt, firststate, bf.spin)) {
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
h->alt = alt;
|
||||
alt->cdata = (cdata*) h;
|
||||
currentmap->link_alt(bf);
|
||||
|
||||
for(int d=rad; d>=0; d--) {
|
||||
currentmap->generateAlts(cx[d]->master);
|
||||
|
2
cell.cpp
2
cell.cpp
@ -20,7 +20,7 @@ struct hrmap {
|
||||
virtual vector<cell*>& allcells();
|
||||
virtual void verify() { }
|
||||
virtual void on_dim_change() { }
|
||||
virtual void link_alt(const cellwalker& hs) { }
|
||||
virtual bool link_alt(heptagon *h, heptagon *alt, hstate firststate, int dir) { return true; }
|
||||
virtual void generateAlts(heptagon *h, int levs = default_levs(), bool link_cdata = true);
|
||||
heptagon *may_create_step(heptagon *h, int direction) {
|
||||
if(h->move(direction)) return h->move(direction);
|
||||
|
20
reg3.cpp
20
reg3.cpp
@ -1518,10 +1518,10 @@ EX namespace reg3 {
|
||||
|
||||
map<heptagon*, int> reducers;
|
||||
|
||||
void link_alt(const cellwalker& hs) override {
|
||||
auto h = hs.at->master;
|
||||
bool link_alt(heptagon *h, heptagon *alt, hstate firststate, int dir) override {
|
||||
altdist(h) = 0;
|
||||
if(h->alt->s != hsOrigin) reducers[h] = hs.spin;
|
||||
if(firststate != hsOrigin) reducers[h] = dir;
|
||||
return true;
|
||||
}
|
||||
|
||||
void generateAlts(heptagon* h, int levs, bool link_cdata) override {
|
||||
@ -2075,6 +2075,8 @@ EX namespace reg3 {
|
||||
int aid = cell_id.at(c);
|
||||
return quotient_map->get_move_seq(quotient_map->acells[aid], i);
|
||||
}
|
||||
|
||||
virtual bool link_alt(heptagon *h, heptagon *alt, hstate firststate, int dir) override;
|
||||
};
|
||||
|
||||
struct hrmap_h3_rule_alt : hrmap {
|
||||
@ -2091,25 +2093,25 @@ EX hrmap *new_alt_map(heptagon *o) {
|
||||
return new hrmap_h3_rule_alt(o);
|
||||
}
|
||||
|
||||
EX void link_structures(heptagon *h, heptagon *alt, hstate firststate) {
|
||||
auto cm = (hrmap_h3_rule*) currentmap;
|
||||
bool hrmap_h3_rule::link_alt(heptagon *h, heptagon *alt, hstate firststate, int dir) {
|
||||
alt->fieldval = h->fieldval;
|
||||
if(geometry == gSpace535) alt->fieldval = 0;
|
||||
if(firststate == hsOrigin) {
|
||||
alt->fiftyval = cm->root[alt->fieldval];
|
||||
return;
|
||||
alt->fiftyval = root[alt->fieldval];
|
||||
return true;
|
||||
}
|
||||
vector<int>& choices = cm->possible_states[alt->fieldval];
|
||||
vector<int>& choices = possible_states[alt->fieldval];
|
||||
vector<int> choices2;
|
||||
for(auto c: choices) {
|
||||
bool ok = true;
|
||||
for(int d=0; d<12; d++)
|
||||
if(h->cmove(d)->distance < h->distance)
|
||||
if(cm->children[S7*c+d] == -1)
|
||||
if(children[S7*c+d] == -1)
|
||||
ok = false;
|
||||
if(ok) choices2.push_back(c);
|
||||
}
|
||||
alt->fiftyval = hrand_elt(choices2, -1);
|
||||
return alt->fiftyval != -1;
|
||||
}
|
||||
|
||||
EX bool reg3_rule_available = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user