mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-07-13 06:32:51 +00:00
emeraldmaps now implemented for hrmap_h3_subrule
This commit is contained in:
parent
21dfe6a27f
commit
2e2dc2aac0
138
reg3.cpp
138
reg3.cpp
@ -2034,10 +2034,62 @@ EX namespace reg3 {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct hrmap_h3_rule : hrmap_h3_abstract, ruleset {
|
struct emerald_matcher {
|
||||||
|
reg3::hrmap_quotient3 *emerald_map;
|
||||||
|
|
||||||
|
vector<short> evmemo;
|
||||||
|
|
||||||
|
void find_emeraldval(heptagon *target, heptagon *parent, int d, hrmap_quotient3* qmap, int parent_fieldval) {
|
||||||
|
generate_cellrotations();
|
||||||
|
auto& cr = cgi.cellrotations;
|
||||||
|
if(evmemo.empty()) {
|
||||||
|
println(hlog, "starting");
|
||||||
|
map<int, int> matrix_hashtable;
|
||||||
|
auto matrix_hash = [] (const transmatrix& M) {
|
||||||
|
return bucketer(M[0][0])
|
||||||
|
+ bucketer(M[0][1]) * 71
|
||||||
|
+ bucketer(M[0][2]) * 113
|
||||||
|
+ bucketer(M[1][0]) * 1301
|
||||||
|
+ bucketer(M[1][1]) * 1703
|
||||||
|
+ bucketer(M[1][2]) * 17031
|
||||||
|
+ bucketer(M[2][2]) * 2307
|
||||||
|
+ bucketer(M[2][0]) * 2311
|
||||||
|
+ bucketer(M[2][1]) * 10311;
|
||||||
|
};
|
||||||
|
for(int i=0; i<isize(cr); i++) matrix_hashtable[matrix_hash(cr[i].M)] = cr[i].inverse_id;
|
||||||
|
println(hlog, "ids size = ", isize(matrix_hashtable));
|
||||||
|
|
||||||
|
for(int eid=0; eid<isize(emerald_map->allh); eid++)
|
||||||
|
for(int k0=0; k0<isize(cr); k0++)
|
||||||
|
for(int fv=0; fv<isize(qmap->allh); fv++) {
|
||||||
|
for(int d=0; d<S7; d++) {
|
||||||
|
int ed = cr[k0].mapping[d];
|
||||||
|
auto cpart = emerald_map->allh[eid];
|
||||||
|
int eid1 = emerald_map->allh[eid]->move(ed)->fieldval;
|
||||||
|
const transmatrix& X = cr[cr[k0].inverse_id].M;
|
||||||
|
transmatrix U = qmap->iadj(qmap->allh[fv], d) * X * emerald_map->adj(cpart, ed);
|
||||||
|
int k1 = matrix_hashtable[matrix_hash(U)];
|
||||||
|
/* for(int ik1=0; ik1<isize(cr); ik1++) {
|
||||||
|
auto& mX1 = cr[ik1].M;
|
||||||
|
if(eqmatrix(mX1, U)) k1 = cr[ik1].inverse_id;
|
||||||
|
} */
|
||||||
|
evmemo.push_back(eid1 * isize(cr) + k1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println(hlog, "generated ", isize(evmemo));
|
||||||
|
}
|
||||||
|
int memo_id = parent->emeraldval;
|
||||||
|
memo_id = memo_id * isize(qmap->allh) + parent_fieldval;
|
||||||
|
memo_id = memo_id * S7 + d;
|
||||||
|
target->emeraldval = evmemo[memo_id];
|
||||||
|
target->zebraval = emerald_map->allh[target->emeraldval / isize(cr)]->zebraval;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
struct hrmap_h3_rule : hrmap_h3_abstract, ruleset, emerald_matcher {
|
||||||
|
|
||||||
heptagon *origin;
|
heptagon *origin;
|
||||||
reg3::hrmap_quotient3 *emerald_map;
|
|
||||||
|
|
||||||
hrmap_quotient3 *qmap() override { return quotient_map; }
|
hrmap_quotient3 *qmap() override { return quotient_map; }
|
||||||
|
|
||||||
@ -2076,54 +2128,6 @@ EX namespace reg3 {
|
|||||||
return quotient_map->allh[h->fieldval];
|
return quotient_map->allh[h->fieldval];
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<short> evmemo;
|
|
||||||
|
|
||||||
void find_emeraldval(heptagon *target, heptagon *parent, int d) {
|
|
||||||
generate_cellrotations();
|
|
||||||
auto& cr = cgi.cellrotations;
|
|
||||||
if(evmemo.empty()) {
|
|
||||||
println(hlog, "starting");
|
|
||||||
map<int, int> matrix_hashtable;
|
|
||||||
auto matrix_hash = [] (const transmatrix& M) {
|
|
||||||
return bucketer(M[0][0])
|
|
||||||
+ bucketer(M[0][1]) * 71
|
|
||||||
+ bucketer(M[0][2]) * 113
|
|
||||||
+ bucketer(M[1][0]) * 1301
|
|
||||||
+ bucketer(M[1][1]) * 1703
|
|
||||||
+ bucketer(M[1][2]) * 17031
|
|
||||||
+ bucketer(M[2][2]) * 2307
|
|
||||||
+ bucketer(M[2][0]) * 2311
|
|
||||||
+ bucketer(M[2][1]) * 10311;
|
|
||||||
};
|
|
||||||
for(int i=0; i<isize(cr); i++) matrix_hashtable[matrix_hash(cr[i].M)] = cr[i].inverse_id;
|
|
||||||
println(hlog, "ids size = ", isize(matrix_hashtable));
|
|
||||||
|
|
||||||
for(int eid=0; eid<isize(emerald_map->allh); eid++)
|
|
||||||
for(int k0=0; k0<isize(cr); k0++)
|
|
||||||
for(int fv=0; fv<isize(quotient_map->allh); fv++) {
|
|
||||||
for(int d=0; d<S7; d++) {
|
|
||||||
int ed = cr[k0].mapping[d];
|
|
||||||
auto cpart = emerald_map->allh[eid];
|
|
||||||
int eid1 = emerald_map->allh[eid]->move(ed)->fieldval;
|
|
||||||
const transmatrix& X = cr[cr[k0].inverse_id].M;
|
|
||||||
transmatrix U = quotient_map->iadj(quotient_map->allh[fv], d) * X * emerald_map->adj(cpart, ed);
|
|
||||||
int k1 = matrix_hashtable[matrix_hash(U)];
|
|
||||||
/* for(int ik1=0; ik1<isize(cr); ik1++) {
|
|
||||||
auto& mX1 = cr[ik1].M;
|
|
||||||
if(eqmatrix(mX1, U)) k1 = cr[ik1].inverse_id;
|
|
||||||
} */
|
|
||||||
evmemo.push_back(eid1 * isize(cr) + k1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
println(hlog, "generated ", isize(evmemo));
|
|
||||||
}
|
|
||||||
int memo_id = parent->emeraldval;
|
|
||||||
memo_id = memo_id * isize(quotient_map->allh) + parent->fieldval;
|
|
||||||
memo_id = memo_id * S7 + d;
|
|
||||||
target->emeraldval = evmemo[memo_id];
|
|
||||||
target->zebraval = emerald_map->allh[target->emeraldval / isize(cr)]->zebraval;
|
|
||||||
}
|
|
||||||
|
|
||||||
heptagon *create_step(heptagon *parent, int d) override {
|
heptagon *create_step(heptagon *parent, int d) override {
|
||||||
int id = parent->fiftyval;
|
int id = parent->fiftyval;
|
||||||
if(id < 0) id += (1<<16);
|
if(id < 0) id += (1<<16);
|
||||||
@ -2154,7 +2158,7 @@ EX namespace reg3 {
|
|||||||
res->fieldval = fv;
|
res->fieldval = fv;
|
||||||
res->distance = parent->distance + 1;
|
res->distance = parent->distance + 1;
|
||||||
res->fiftyval = id1;
|
res->fiftyval = id1;
|
||||||
find_emeraldval(res, parent, d);
|
find_emeraldval(res, parent, d, quotient_map, parent->fieldval);
|
||||||
// res->c.connect(d2, parent, d, false);
|
// res->c.connect(d2, parent, d, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2168,7 +2172,7 @@ EX namespace reg3 {
|
|||||||
for(auto s: nonlooping_earlier_states[address{pfv, id}]) possible.push_back(s.second);
|
for(auto s: nonlooping_earlier_states[address{pfv, id}]) possible.push_back(s.second);
|
||||||
id1 = hrand_elt(possible, 0);
|
id1 = hrand_elt(possible, 0);
|
||||||
res->fiftyval = id1;
|
res->fiftyval = id1;
|
||||||
find_emeraldval(res, parent, d);
|
find_emeraldval(res, parent, d, quotient_map, parent->fieldval);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
@ -2209,7 +2213,7 @@ EX namespace reg3 {
|
|||||||
|
|
||||||
vector<heptspin> starts = {nullptr};
|
vector<heptspin> starts = {nullptr};
|
||||||
|
|
||||||
struct hrmap_h3_subrule : hrmap, ruleset {
|
struct hrmap_h3_subrule : hrmap, ruleset, emerald_matcher {
|
||||||
|
|
||||||
heptagon *origin;
|
heptagon *origin;
|
||||||
hrmap_quotient3 *quotient_map;
|
hrmap_quotient3 *quotient_map;
|
||||||
@ -2274,12 +2278,33 @@ EX namespace reg3 {
|
|||||||
h.fieldval = 0;
|
h.fieldval = 0;
|
||||||
h.fiftyval = root[0];
|
h.fiftyval = root[0];
|
||||||
h.c7 = newCell(t, origin);
|
h.c7 = newCell(t, origin);
|
||||||
|
|
||||||
|
if(1) {
|
||||||
|
dynamicval<eVariation> dv(variation, eVariation::pure);
|
||||||
|
dynamicval<geometry_information*> dc(cgip, cgip);
|
||||||
|
check_cgi(); cgi.require_basics();
|
||||||
|
emerald_map = gen_quotient_map(false, currfp);
|
||||||
|
h.emeraldval = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
heptagon *getOrigin() override {
|
heptagon *getOrigin() override {
|
||||||
return origin;
|
return origin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void find_emeraldval_path(heptagon *res, heptagon *parent, int d, cell *cpart) {
|
||||||
|
auto& mseq = quotient_map->get_move_seq(cpart, d);
|
||||||
|
res->emeraldval = parent->emeraldval;
|
||||||
|
res->zebraval = parent->zebraval;
|
||||||
|
heptagon *h = cpart->master;
|
||||||
|
for(auto m: mseq) {
|
||||||
|
find_emeraldval(res, res, m, quotient_map, h->fieldval);
|
||||||
|
h = h->move(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
hassert(h == quotient_map->acells[res->fieldval]->master);
|
||||||
|
}
|
||||||
|
|
||||||
heptagon *create_step(heptagon *parent, int d) override {
|
heptagon *create_step(heptagon *parent, int d) override {
|
||||||
heptspin parentd(parent, d);
|
heptspin parentd(parent, d);
|
||||||
if(starts[isize(starts)/2] == parentd) {
|
if(starts[isize(starts)/2] == parentd) {
|
||||||
@ -2298,8 +2323,9 @@ EX namespace reg3 {
|
|||||||
|
|
||||||
int qid = parent->fieldval;
|
int qid = parent->fieldval;
|
||||||
|
|
||||||
int d2 = quotient_map->acells[qid]->c.spin(d);
|
auto cpart = quotient_map->acells[qid];
|
||||||
int qid2 = quotient_map->local_id[quotient_map->acells[qid]->move(d)].first;
|
int d2 = cpart->c.spin(d);
|
||||||
|
int qid2 = quotient_map->local_id[cpart->move(d)].first;
|
||||||
|
|
||||||
heptagon *res = nullptr;
|
heptagon *res = nullptr;
|
||||||
|
|
||||||
@ -2314,6 +2340,7 @@ EX namespace reg3 {
|
|||||||
res->fieldval = qid2;
|
res->fieldval = qid2;
|
||||||
res->distance = parent->distance + 1;
|
res->distance = parent->distance + 1;
|
||||||
res->fiftyval = id1;
|
res->fiftyval = id1;
|
||||||
|
find_emeraldval_path(res, parent, d, cpart);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(other[pos] == ('A' + d) && other[pos+1] == ',') {
|
else if(other[pos] == ('A' + d) && other[pos+1] == ',') {
|
||||||
@ -2328,6 +2355,7 @@ EX namespace reg3 {
|
|||||||
res->fieldval = qid2;
|
res->fieldval = qid2;
|
||||||
res->distance = parent->distance - 1;
|
res->distance = parent->distance - 1;
|
||||||
res->fiftyval = id1;
|
res->fiftyval = id1;
|
||||||
|
find_emeraldval_path(res, parent, d, cpart);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user