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;
|
if(!polarb50(c)) return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bf += rev;
|
||||||
|
|
||||||
heptagon *alt = init_heptagon(h->type);
|
heptagon *alt = init_heptagon(h->type);
|
||||||
allmaps.push_back(newAltMap(alt));
|
allmaps.push_back(newAltMap(alt));
|
||||||
//printf("new alt {%p}\n", hr::voidp(alt));
|
//printf("new alt {%p}\n", hr::voidp(alt));
|
||||||
alt->s = firststate;
|
alt->s = firststate;
|
||||||
if(hybri) alt->fieldval = hybrid::get_where(centerover).second;
|
if(hybri) alt->fieldval = hybrid::get_where(centerover).second;
|
||||||
alt->alt = alt;
|
alt->alt = alt;
|
||||||
#if MAXMDIM >= 4
|
if(!currentmap->link_alt(h, alt, firststate, bf.spin)) {
|
||||||
if(reg3::in_rule()) {
|
return nullptr;
|
||||||
reg3::link_structures(h, alt, firststate);
|
|
||||||
if(alt->fiftyval == -1) return nullptr; /* unlinked */
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
h->alt = alt;
|
h->alt = alt;
|
||||||
alt->cdata = (cdata*) h;
|
alt->cdata = (cdata*) h;
|
||||||
currentmap->link_alt(bf);
|
|
||||||
|
|
||||||
for(int d=rad; d>=0; d--) {
|
for(int d=rad; d>=0; d--) {
|
||||||
currentmap->generateAlts(cx[d]->master);
|
currentmap->generateAlts(cx[d]->master);
|
||||||
|
|
2
cell.cpp
2
cell.cpp
|
@ -20,7 +20,7 @@ struct hrmap {
|
||||||
virtual vector<cell*>& allcells();
|
virtual vector<cell*>& allcells();
|
||||||
virtual void verify() { }
|
virtual void verify() { }
|
||||||
virtual void on_dim_change() { }
|
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);
|
virtual void generateAlts(heptagon *h, int levs = default_levs(), bool link_cdata = true);
|
||||||
heptagon *may_create_step(heptagon *h, int direction) {
|
heptagon *may_create_step(heptagon *h, int direction) {
|
||||||
if(h->move(direction)) return h->move(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;
|
map<heptagon*, int> reducers;
|
||||||
|
|
||||||
void link_alt(const cellwalker& hs) override {
|
bool link_alt(heptagon *h, heptagon *alt, hstate firststate, int dir) override {
|
||||||
auto h = hs.at->master;
|
|
||||||
altdist(h) = 0;
|
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 {
|
void generateAlts(heptagon* h, int levs, bool link_cdata) override {
|
||||||
|
@ -2075,6 +2075,8 @@ EX namespace reg3 {
|
||||||
int aid = cell_id.at(c);
|
int aid = cell_id.at(c);
|
||||||
return quotient_map->get_move_seq(quotient_map->acells[aid], i);
|
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 {
|
struct hrmap_h3_rule_alt : hrmap {
|
||||||
|
@ -2091,25 +2093,25 @@ EX hrmap *new_alt_map(heptagon *o) {
|
||||||
return new hrmap_h3_rule_alt(o);
|
return new hrmap_h3_rule_alt(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
EX void link_structures(heptagon *h, heptagon *alt, hstate firststate) {
|
bool hrmap_h3_rule::link_alt(heptagon *h, heptagon *alt, hstate firststate, int dir) {
|
||||||
auto cm = (hrmap_h3_rule*) currentmap;
|
|
||||||
alt->fieldval = h->fieldval;
|
alt->fieldval = h->fieldval;
|
||||||
if(geometry == gSpace535) alt->fieldval = 0;
|
if(geometry == gSpace535) alt->fieldval = 0;
|
||||||
if(firststate == hsOrigin) {
|
if(firststate == hsOrigin) {
|
||||||
alt->fiftyval = cm->root[alt->fieldval];
|
alt->fiftyval = root[alt->fieldval];
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
vector<int>& choices = cm->possible_states[alt->fieldval];
|
vector<int>& choices = possible_states[alt->fieldval];
|
||||||
vector<int> choices2;
|
vector<int> choices2;
|
||||||
for(auto c: choices) {
|
for(auto c: choices) {
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
for(int d=0; d<12; d++)
|
for(int d=0; d<12; d++)
|
||||||
if(h->cmove(d)->distance < h->distance)
|
if(h->cmove(d)->distance < h->distance)
|
||||||
if(cm->children[S7*c+d] == -1)
|
if(children[S7*c+d] == -1)
|
||||||
ok = false;
|
ok = false;
|
||||||
if(ok) choices2.push_back(c);
|
if(ok) choices2.push_back(c);
|
||||||
}
|
}
|
||||||
alt->fiftyval = hrand_elt(choices2, -1);
|
alt->fiftyval = hrand_elt(choices2, -1);
|
||||||
|
return alt->fiftyval != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
EX bool reg3_rule_available = true;
|
EX bool reg3_rule_available = true;
|
||||||
|
|
Loading…
Reference in New Issue