mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-04-27 21:23:19 +00:00
fieldval_uniq moved to virtual method pattern_value
This commit is contained in:
parent
2e2dc2aac0
commit
08d73c507f
@ -1625,6 +1625,8 @@ struct hrmap_arbi : hrmap {
|
|||||||
return id_of(c->master);
|
return id_of(c->master);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pattern_value(cell *c) override { return id_of(c->master); }
|
||||||
|
|
||||||
hyperpoint get_corner(cell *c, int cid, ld cf) override {
|
hyperpoint get_corner(cell *c, int cid, ld cf) override {
|
||||||
auto& sh = arb::current_or_slided().shapes[arb::id_of(c->master)];
|
auto& sh = arb::current_or_slided().shapes[arb::id_of(c->master)];
|
||||||
int id = gmod(cid, c->type);
|
int id = gmod(cid, c->type);
|
||||||
|
@ -888,6 +888,11 @@ struct hrmap_archimedean : hrmap {
|
|||||||
return C0;
|
return C0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pattern_value(cell *c) override {
|
||||||
|
if(sphere) return c->master->fiftyval;
|
||||||
|
return hrmap::pattern_value(c);
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EX hrmap *new_map() { return new hrmap_archimedean; }
|
EX hrmap *new_map() { return new hrmap_archimedean; }
|
||||||
|
16
cell.cpp
16
cell.cpp
@ -13,6 +13,8 @@ namespace hr {
|
|||||||
#if HDR
|
#if HDR
|
||||||
extern int default_levs();
|
extern int default_levs();
|
||||||
|
|
||||||
|
constexpr int PATTERN_INVALID = -1;
|
||||||
|
|
||||||
struct hrmap {
|
struct hrmap {
|
||||||
virtual heptagon *getOrigin() { return NULL; }
|
virtual heptagon *getOrigin() { return NULL; }
|
||||||
virtual cell *gamestart() { return getOrigin()->c7; }
|
virtual cell *gamestart() { return getOrigin()->c7; }
|
||||||
@ -82,6 +84,10 @@ public:
|
|||||||
transmatrix adjmod(heptagon *h, int i) { return adj(h, gmod(i, h->type)); }
|
transmatrix adjmod(heptagon *h, int i) { return adj(h, gmod(i, h->type)); }
|
||||||
transmatrix iadjmod(cell *c, int i) { return iadj(c, gmod(i, c->type)); }
|
transmatrix iadjmod(cell *c, int i) { return iadj(c, gmod(i, c->type)); }
|
||||||
transmatrix iadjmod(heptagon *h, int i) { return iadj(h, gmod(i, h->type)); }
|
transmatrix iadjmod(heptagon *h, int i) { return iadj(h, gmod(i, h->type)); }
|
||||||
|
|
||||||
|
/** this takes a large closed manifold M that is a quotient of this, and returns a unique identifier of the cell corresponding to M
|
||||||
|
* returns PATTERN_INVALID if not implemented or impossible */
|
||||||
|
virtual int pattern_value(cell *c) { return PATTERN_INVALID; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/** hrmaps which are based on regular non-Euclidean 2D tilings, possibly quotient
|
/** hrmaps which are based on regular non-Euclidean 2D tilings, possibly quotient
|
||||||
@ -104,6 +110,7 @@ struct hrmap_standard : hrmap {
|
|||||||
transmatrix master_relative(cell *c, bool get_inverse) override;
|
transmatrix master_relative(cell *c, bool get_inverse) override;
|
||||||
bool link_alt(heptagon *h, heptagon *alt, hstate firststate, int dir) override;
|
bool link_alt(heptagon *h, heptagon *alt, hstate firststate, int dir) override;
|
||||||
void on_dim_change() override;
|
void on_dim_change() override;
|
||||||
|
int pattern_value(cell *c) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
void clearfrom(heptagon*);
|
void clearfrom(heptagon*);
|
||||||
@ -124,6 +131,15 @@ struct hrmap_hyperbolic : hrmap_standard {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int hrmap_standard::pattern_value(cell *c) {
|
||||||
|
if(&currfp == &fieldpattern::fp_invalid) return 0;
|
||||||
|
if(ctof(c) || NONSTDVAR) return c->master->fieldval/S7;
|
||||||
|
int z = 0;
|
||||||
|
for(int u=0; u<S6; u+=2)
|
||||||
|
z = max(z, fieldpattern::btspin(createMov(c, u)->master->fieldval, c->c.spin(u)));
|
||||||
|
return -1-z;
|
||||||
|
}
|
||||||
|
|
||||||
void hrmap_standard::on_dim_change() {
|
void hrmap_standard::on_dim_change() {
|
||||||
for(auto& p: gp::gp_swapped) swapmatrix(gp::gp_adj[p]);
|
for(auto& p: gp::gp_swapped) swapmatrix(gp::gp_adj[p]);
|
||||||
gp::gp_swapped.clear();
|
gp::gp_swapped.clear();
|
||||||
|
14
euclid.cpp
14
euclid.cpp
@ -303,6 +303,20 @@ EX namespace euc {
|
|||||||
subcellshape& get_cellshape(cell* c) override {
|
subcellshape& get_cellshape(cell* c) override {
|
||||||
return *cgi.heptshape;
|
return *cgi.heptshape;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pattern_value(cell *c) override {
|
||||||
|
if(WDIM == 2) {
|
||||||
|
auto p = euc2_coordinates(c);
|
||||||
|
if(closed_manifold) return p.first + p.second * (1 << 16);
|
||||||
|
return gmod(p.first - 22 * p.second, 3*127);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
auto co = ispacemap[c->master];
|
||||||
|
if(closed_manifold) return co[0] + (co[1] << 10) + (co[2] << 20);
|
||||||
|
return gmod(co[0] + 3 * co[1] + 9 * co[2], 3*127);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
hrmap_euclidean* cubemap() {
|
hrmap_euclidean* cubemap() {
|
||||||
|
2
fake.cpp
2
fake.cpp
@ -418,6 +418,8 @@ EX namespace fake {
|
|||||||
return FPIU( currentmap->shvid(c) );
|
return FPIU( currentmap->shvid(c) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pattern_value(cell *c) override { return FPIU( currentmap->pattern_value(c)); }
|
||||||
|
|
||||||
subcellshape& get_cellshape(cell *c) override {
|
subcellshape& get_cellshape(cell *c) override {
|
||||||
return *FPIU( (cgip = pcgip, &(currentmap->get_cellshape(c))) );
|
return *FPIU( (cgip = pcgip, &(currentmap->get_cellshape(c))) );
|
||||||
}
|
}
|
||||||
|
@ -1554,6 +1554,11 @@ EX namespace hybrid {
|
|||||||
int id = full_shvid(c);
|
int id = full_shvid(c);
|
||||||
return generate_subcellshape_if_needed(c, id);
|
return generate_subcellshape_if_needed(c, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pattern_value(cell *c) override {
|
||||||
|
auto c1 = hybrid::get_where(c).first;
|
||||||
|
return PIU ( currentmap->pattern_value(c1) );
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
hrmap_hybrid* hmap() { return (hrmap_hybrid*) currentmap; }
|
hrmap_hybrid* hmap() { return (hrmap_hybrid*) currentmap; }
|
||||||
|
41
pattern2.cpp
41
pattern2.cpp
@ -420,46 +420,7 @@ EX pair<int, bool> fieldval(cell *c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EX int fieldval_uniq(cell *c) {
|
EX int fieldval_uniq(cell *c) {
|
||||||
if(fake::in()) return FPIU(fieldval_uniq(c));
|
return currentmap->pattern_value(c);
|
||||||
if(experimental) return 0;
|
|
||||||
if(reg3::in() && !PURE) return 0;
|
|
||||||
else if(arb::in()) return arb::id_of(c->master);
|
|
||||||
else if(mhybrid) {
|
|
||||||
auto c1 = hybrid::get_where(c).first;
|
|
||||||
return PIU ( fieldval_uniq(c1) );
|
|
||||||
}
|
|
||||||
else if(msphere) {
|
|
||||||
if(arcm::in()) return c->master->fiftyval;
|
|
||||||
#if CAP_IRR
|
|
||||||
else if(IRREGULAR) return irr::cellindex[c];
|
|
||||||
#endif
|
|
||||||
#if CAP_GP
|
|
||||||
else if(GOLDBERG_INV) return (get_code(gp::get_local_info(c)) << 8) | (sphere ? c->master->fieldval : c->master->fieldval / S7);
|
|
||||||
#endif
|
|
||||||
if(ctof(c)) return c->master->fieldval;
|
|
||||||
else return createMov(c, 0)->master->fieldval + 256 * createMov(c,2)->master->fieldval + (1<<16) * createMov(c,4)->master->fieldval;
|
|
||||||
}
|
|
||||||
else if(euc::in(2)) {
|
|
||||||
auto p = euc2_coordinates(c);
|
|
||||||
if(closed_manifold) return p.first + p.second * (1 << 16);
|
|
||||||
return gmod(p.first - 22 * p.second, 3*127);
|
|
||||||
}
|
|
||||||
else if(euc::in(3)) {
|
|
||||||
auto co = euc::get_ispacemap()[c->master];
|
|
||||||
if(closed_manifold) return co[0] + (co[1] << 10) + (co[2] << 20);
|
|
||||||
return gmod(co[0] + 3 * co[1] + 9 * co[2], 3*127);
|
|
||||||
}
|
|
||||||
else if(bt::in() || arcm::in() || nil || S3 >= OINF || (cgflags & qIDEAL)) return 0;
|
|
||||||
else if(&currfp == &fp_invalid) return 0;
|
|
||||||
else if(geometry == gSpace535) return 0;
|
|
||||||
else if(WDIM == 3) return c->master->fieldval;
|
|
||||||
else if(ctof(c) || NONSTDVAR) return c->master->fieldval/S7;
|
|
||||||
else {
|
|
||||||
int z = 0;
|
|
||||||
for(int u=0; u<S6; u+=2)
|
|
||||||
z = max(z, btspin(createMov(c, u)->master->fieldval, c->c.spin(u)));
|
|
||||||
return -1-z;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EX int fieldval_uniq_rand(cell *c, int randval) {
|
EX int fieldval_uniq_rand(cell *c, int randval) {
|
||||||
|
32
reg3.cpp
32
reg3.cpp
@ -793,6 +793,10 @@ EX namespace reg3 {
|
|||||||
int id = local_id.at(c).first;
|
int id = local_id.at(c).first;
|
||||||
return move_sequences[id][i];
|
return move_sequences[id][i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pattern_value(cell *c) override {
|
||||||
|
return local_id[c].first;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct hrmap_quotient3 : hrmap_closed3 { };
|
struct hrmap_quotient3 : hrmap_closed3 { };
|
||||||
@ -1752,6 +1756,10 @@ EX namespace reg3 {
|
|||||||
extra_origins.push_back(created);
|
extra_origins.push_back(created);
|
||||||
return get_cell_at(created, fv);
|
return get_cell_at(created, fv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pattern_value(cell *c) override {
|
||||||
|
return c->master->fieldval;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EX int get_aid(cell *c) {
|
EX int get_aid(cell *c) {
|
||||||
@ -2037,12 +2045,16 @@ EX namespace reg3 {
|
|||||||
struct emerald_matcher {
|
struct emerald_matcher {
|
||||||
reg3::hrmap_quotient3 *emerald_map;
|
reg3::hrmap_quotient3 *emerald_map;
|
||||||
|
|
||||||
|
int crsize;
|
||||||
vector<short> evmemo;
|
vector<short> evmemo;
|
||||||
|
|
||||||
|
emerald_matcher() { crsize = 1; }
|
||||||
|
|
||||||
void find_emeraldval(heptagon *target, heptagon *parent, int d, hrmap_quotient3* qmap, int parent_fieldval) {
|
void find_emeraldval(heptagon *target, heptagon *parent, int d, hrmap_quotient3* qmap, int parent_fieldval) {
|
||||||
generate_cellrotations();
|
generate_cellrotations();
|
||||||
auto& cr = cgi.cellrotations;
|
auto& cr = cgi.cellrotations;
|
||||||
if(evmemo.empty()) {
|
if(evmemo.empty()) {
|
||||||
|
crsize = isize(cr);
|
||||||
println(hlog, "starting");
|
println(hlog, "starting");
|
||||||
map<int, int> matrix_hashtable;
|
map<int, int> matrix_hashtable;
|
||||||
auto matrix_hash = [] (const transmatrix& M) {
|
auto matrix_hash = [] (const transmatrix& M) {
|
||||||
@ -2082,7 +2094,7 @@ EX namespace reg3 {
|
|||||||
memo_id = memo_id * isize(qmap->allh) + parent_fieldval;
|
memo_id = memo_id * isize(qmap->allh) + parent_fieldval;
|
||||||
memo_id = memo_id * S7 + d;
|
memo_id = memo_id * S7 + d;
|
||||||
target->emeraldval = evmemo[memo_id];
|
target->emeraldval = evmemo[memo_id];
|
||||||
target->zebraval = emerald_map->allh[target->emeraldval / isize(cr)]->zebraval;
|
target->zebraval = emerald_map->allh[target->emeraldval / crsize]->zebraval;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -2209,6 +2221,15 @@ EX namespace reg3 {
|
|||||||
bool link_alt(heptagon *h, heptagon *alt, hstate firststate, int dir) override {
|
bool link_alt(heptagon *h, heptagon *alt, hstate firststate, int dir) override {
|
||||||
return ruleset_link_alt(h, alt, firststate, dir);
|
return ruleset_link_alt(h, alt, firststate, dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pattern_value(cell *c) override {
|
||||||
|
int id = c->master->emeraldval / crsize;
|
||||||
|
if(!PURE) {
|
||||||
|
id <<= 16;
|
||||||
|
id |= cell_id[c];
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
vector<heptspin> starts = {nullptr};
|
vector<heptspin> starts = {nullptr};
|
||||||
@ -2492,6 +2513,15 @@ EX namespace reg3 {
|
|||||||
println(f);
|
println(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pattern_value(cell *c) override {
|
||||||
|
int id = c->master->emeraldval / crsize;
|
||||||
|
if(!PURE) {
|
||||||
|
id <<= 16;
|
||||||
|
id |= quotient_map->local_id[quotient_map->acells[c->master->fieldval]].second;
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct hrmap_h3_rule_alt : hrmap {
|
struct hrmap_h3_rule_alt : hrmap {
|
||||||
|
12
sphere.cpp
12
sphere.cpp
@ -183,6 +183,18 @@ struct hrmap_spherical : hrmap_standard {
|
|||||||
if(elliptic) fixelliptic(T);
|
if(elliptic) fixelliptic(T);
|
||||||
return T;
|
return T;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pattern_value(cell *c) override {
|
||||||
|
#if CAP_IRR
|
||||||
|
if(IRREGULAR) return irr::cellindex[c];
|
||||||
|
#endif
|
||||||
|
#if CAP_GP
|
||||||
|
if(GOLDBERG_INV) return (get_code(gp::get_local_info(c)) << 8) | c->master->fieldval;
|
||||||
|
#endif
|
||||||
|
if(ctof(c)) return c->master->fieldval;
|
||||||
|
return createMov(c, 0)->master->fieldval + 256 * createMov(c,2)->master->fieldval + (1<<16) * createMov(c,4)->master->fieldval;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EX heptagon *getDodecahedron(int i) {
|
EX heptagon *getDodecahedron(int i) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user