mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-25 01:20:37 +00:00
reg3:: factored gen_quotient_map
This commit is contained in:
parent
3f56f158ee
commit
a6116d678e
@ -723,7 +723,7 @@ EX color_t colorize(cell *c, char whichCanvas) {
|
|||||||
if(cryst) co = m->get_coord(c), dim = m->cs.dim;
|
if(cryst) co = m->get_coord(c), dim = m->cs.dim;
|
||||||
#if MAXMDIM >= 4
|
#if MAXMDIM >= 4
|
||||||
else if(geometry == gSpace344) {
|
else if(geometry == gSpace344) {
|
||||||
co = told(reg3::decode_coord(c->master->fieldval)), dim = 4;
|
co = told(reg3::decode_coord(reg3::minimize_quotient_maps ? 1 : 2, c->master->fieldval)), dim = 4;
|
||||||
for(int a=0; a<4; a++) if(co[a] > 4) co[a] -= 8;
|
for(int a=0; a<4; a++) if(co[a] > 4) co[a] -= 8;
|
||||||
}
|
}
|
||||||
else if(geometry == gSeifertCover) {
|
else if(geometry == gSeifertCover) {
|
||||||
|
82
reg3.cpp
82
reg3.cpp
@ -1014,30 +1014,32 @@ EX namespace reg3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if CAP_CRYSTAL
|
#if CAP_CRYSTAL
|
||||||
int encode_coord(const crystal::coord& co) {
|
int encode_coord(int bits, const crystal::coord& co) {
|
||||||
int c = 0;
|
int c = 0;
|
||||||
for(int i=0; i<4; i++) c |= ((co[i]>>1) & 3) << (2*i);
|
for(int i=0; i<(1<<bits); i++) c |= ((co[i]>>1) & ((1<<bits)-1)) << (bits*i);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
EX crystal::coord decode_coord(int a) {
|
EX crystal::coord decode_coord(int bits, int a) {
|
||||||
crystal::coord co;
|
crystal::coord co;
|
||||||
for(int i=0; i<4; i++) co[i] = (a & 3) * 2, a >>= 2;
|
for(int i=0; i<(1<<bits); i++) co[i] = (a & ((1<<bits)-1)) * 2, a >>= bits;
|
||||||
return co;
|
return co;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct hrmap_from_crystal : hrmap_quotient3 {
|
struct hrmap_from_crystal : hrmap_quotient3 {
|
||||||
|
int bits;
|
||||||
|
|
||||||
hrmap_from_crystal() {
|
hrmap_from_crystal(int b) : bits(b) {
|
||||||
initialize(256);
|
int size = 1 << (4*bits);
|
||||||
|
initialize(size);
|
||||||
if(1) {
|
if(1) {
|
||||||
auto m = crystal::new_map();
|
auto m = crystal::new_map();
|
||||||
dynamicval<hrmap*> cm(currentmap, m);
|
dynamicval<hrmap*> cm(currentmap, m);
|
||||||
for(int a=0; a<256; a++) {
|
for(int a=0; a<size; a++) {
|
||||||
auto co = decode_coord(a);
|
auto co = decode_coord(bits, a);
|
||||||
heptagon *h1 = get_heptagon_at(co);
|
heptagon *h1 = get_heptagon_at(co);
|
||||||
for(int d=0; d<8; d++) {
|
for(int d=0; d<8; d++) {
|
||||||
int b = encode_coord(crystal::get_coord(h1->cmove(d)));
|
int b = encode_coord(bits, crystal::get_coord(h1->cmove(d)));
|
||||||
allh[a]->c.connect(d, allh[b], h1->c.spin(d), false);
|
allh[a]->c.connect(d, allh[b], h1->c.spin(d), false);
|
||||||
tmatrices[a].push_back(crystal::get_adj(h1, d));
|
tmatrices[a].push_back(crystal::get_adj(h1, d));
|
||||||
}
|
}
|
||||||
@ -1289,6 +1291,28 @@ EX namespace reg3 {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EX bool minimize_quotient_maps = false;
|
||||||
|
|
||||||
|
hrmap_quotient3 *gen_quotient_map(bool minimized, fieldpattern::fpattern &fp) {
|
||||||
|
#if CAP_FIELD
|
||||||
|
#if CAP_CRYSTAL
|
||||||
|
if(geometry == gSpace344) {
|
||||||
|
return new hrmap_from_crystal(minimized ? 1 : 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
if(geometry == gSpace535 && minimized) {
|
||||||
|
return new seifert_weber::hrmap_singlecell(108*degree);
|
||||||
|
}
|
||||||
|
else if(geometry == gSpace535)
|
||||||
|
return new seifert_weber::hrmap_seifert_cover;
|
||||||
|
else if(hyperbolic) {
|
||||||
|
return new hrmap_field3(&fp);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
struct hrmap_h3 : hrmap {
|
struct hrmap_h3 : hrmap {
|
||||||
|
|
||||||
heptagon *origin;
|
heptagon *origin;
|
||||||
@ -1315,22 +1339,8 @@ EX namespace reg3 {
|
|||||||
transmatrix T = Id;
|
transmatrix T = Id;
|
||||||
|
|
||||||
binary_map = nullptr;
|
binary_map = nullptr;
|
||||||
quotient_map = nullptr;
|
quotient_map = gen_quotient_map(minimize_quotient_maps, currfp);
|
||||||
|
|
||||||
#if CAP_FIELD
|
|
||||||
#if CAP_CRYSTAL
|
|
||||||
if(geometry == gSpace344) {
|
|
||||||
quotient_map = new hrmap_from_crystal;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
if(geometry == gSpace535) {
|
|
||||||
quotient_map = new seifert_weber::hrmap_seifert_cover;
|
|
||||||
}
|
|
||||||
else if(hyperbolic) {
|
|
||||||
quotient_map = new hrmap_field3(&currfp);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
h.zebraval = quotient_map ? quotient_map->allh[0]->zebraval : 0;
|
h.zebraval = quotient_map ? quotient_map->allh[0]->zebraval : 0;
|
||||||
|
|
||||||
#if CAP_BT
|
#if CAP_BT
|
||||||
@ -1816,25 +1826,9 @@ EX namespace reg3 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
quotient_map = nullptr;
|
quotient_map = gen_quotient_map(is_minimized(), fp);
|
||||||
|
emerald_map = gen_quotient_map(false, currfp);
|
||||||
|
|
||||||
if(geometry == gSpace535)
|
|
||||||
quotient_map = new seifert_weber::hrmap_seifert_cover();
|
|
||||||
#if CAP_CRYSTAL
|
|
||||||
else if(geometry == gSpace344)
|
|
||||||
quotient_map = new hrmap_from_crystal;
|
|
||||||
#endif
|
|
||||||
else
|
|
||||||
quotient_map = new hrmap_field3(&fp);
|
|
||||||
|
|
||||||
if(geometry == gSpace535)
|
|
||||||
emerald_map = new seifert_weber::hrmap_seifert_cover();
|
|
||||||
#if CAP_CRYSTAL
|
|
||||||
else if(geometry == gSpace344)
|
|
||||||
emerald_map = new hrmap_from_crystal;
|
|
||||||
#endif
|
|
||||||
else
|
|
||||||
emerald_map = new hrmap_field3(&currfp);
|
|
||||||
h.emeraldval = 0;
|
h.emeraldval = 0;
|
||||||
|
|
||||||
find_mappings();
|
find_mappings();
|
||||||
@ -2122,6 +2116,10 @@ bool hrmap_h3_rule::link_alt(heptagon *h, heptagon *alt, hstate firststate, int
|
|||||||
EX bool reg3_rule_available = true;
|
EX bool reg3_rule_available = true;
|
||||||
EX string other_rule = "";
|
EX string other_rule = "";
|
||||||
|
|
||||||
|
EX bool is_minimized() {
|
||||||
|
return geometry == gSpace535;
|
||||||
|
}
|
||||||
|
|
||||||
EX string get_rule_filename() {
|
EX string get_rule_filename() {
|
||||||
if(other_rule != "") return other_rule;
|
if(other_rule != "") return other_rule;
|
||||||
switch(geometry) {
|
switch(geometry) {
|
||||||
|
Loading…
Reference in New Issue
Block a user