1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-25 01:20:37 +00:00

arb:: patterns configuration

This commit is contained in:
Zeno Rogue 2019-12-27 22:59:50 +01:00
parent c7ec3585ad
commit e4b2453313
4 changed files with 39 additions and 1 deletions

View File

@ -16,6 +16,7 @@ EX namespace arb {
struct shape { struct shape {
int id; int id;
int flags;
vector<hyperpoint> vertices; vector<hyperpoint> vertices;
vector<ld> angles; vector<ld> angles;
vector<ld> edges; vector<ld> edges;
@ -27,6 +28,7 @@ struct shape {
struct arbi_tiling { struct arbi_tiling {
int order; int order;
bool have_line, have_ph;
vector<shape> shapes; vector<shape> shapes;
string name; string name;
@ -85,6 +87,14 @@ void load(const string& fname) {
exp_parser ep; exp_parser ep;
ep.s = s; ep.s = s;
ld angleunit = 1, distunit = 1, angleofs = 0; ld angleunit = 1, distunit = 1, angleofs = 0;
auto addflag = [&] (int f) {
int ai;
if(ep.next() == ')') ai = isize(c.shapes)-1;
else ai = ep.iparse();
verify_index(ai, c.shapes);
c.shapes[ai].flags |= f;
ep.force_eat(")");
};
while(true) { while(true) {
ep.skip_white(); ep.skip_white();
if(ep.next() == 0) break; if(ep.next() == 0) break;
@ -116,6 +126,14 @@ void load(const string& fname) {
else if(ep.eat("angleunit(")) angleunit = real(ep.parsepar()); else if(ep.eat("angleunit(")) angleunit = real(ep.parsepar());
else if(ep.eat("angleofs(")) angleofs = real(ep.parsepar()); else if(ep.eat("angleofs(")) angleofs = real(ep.parsepar());
else if(ep.eat("distunit(")) distunit = real(ep.parsepar()); else if(ep.eat("distunit(")) distunit = real(ep.parsepar());
else if(ep.eat("line(")) {
addflag(arcm::sfLINE);
c.have_line = true;
}
else if(ep.eat("grave(")) {
addflag(arcm::sfPH);
c.have_ph = true;
}
else if(ep.eat("let(")) { else if(ep.eat("let(")) {
string tok = ep.next_token(); string tok = ep.next_token();
ep.force_eat("="); ep.force_eat("=");
@ -125,6 +143,7 @@ void load(const string& fname) {
c.shapes.emplace_back(); c.shapes.emplace_back();
auto& cc = c.shapes.back(); auto& cc = c.shapes.back();
cc.id = isize(c.shapes) - 1; cc.id = isize(c.shapes) - 1;
cc.flags = 0;
while(ep.next() != ')') { while(ep.next() != ')') {
ld dist = ep.rparse(0); ld dist = ep.rparse(0);
ep.force_eat(","); ep.force_eat(",");
@ -370,6 +389,14 @@ EX bool in() { return geometry == gArbitrary; }
EX string tes = "tessellations/marjorie-rice.tes"; EX string tes = "tessellations/marjorie-rice.tes";
EX bool linespattern(cell *c) {
return current.shapes[id_of(c->master)].flags & arcm::sfLINE;
}
EX bool pseudohept(cell *c) {
return current.shapes[id_of(c->master)].flags & arcm::sfPH;
}
EX void choose() { EX void choose() {
dialog::openFileDialog(tes, XLAT("open a tiling"), ".tes", dialog::openFileDialog(tes, XLAT("open a tiling"), ".tes",
[] () { [] () {

View File

@ -84,11 +84,13 @@ struct archimedean_tiling {
#if CAP_ARCM #if CAP_ARCM
#if HDR
static const int sfPH = 1; static const int sfPH = 1;
static const int sfLINE = 2; static const int sfLINE = 2;
static const int sfCHESS = 4; static const int sfCHESS = 4;
static const int sfTHREE = 8; static const int sfTHREE = 8;
static const int sfSEMILINE = 16; static const int sfSEMILINE = 16;
#endif
EX archimedean_tiling current; EX archimedean_tiling current;

View File

@ -597,6 +597,8 @@ EX void giantLandSwitch(cell *c, int d, cell *from) {
else if(arcm::in() && arcm::current.have_line) else if(arcm::in() && arcm::current.have_line)
v = arcm::linespattern(c) ? 24 : 16; v = arcm::linespattern(c) ? 24 : 16;
#endif #endif
else if(arb::in() && arb::current.have_line)
v = arb::linespattern(c) ? 24 : 16;
else if((euclid&&bounded) || hyperbolic_not37 || quotient || arcm::in()) { else if((euclid&&bounded) || hyperbolic_not37 || quotient || arcm::in()) {
v = hrand(100) < 25 ? 24 : 16; v = hrand(100) < 25 ? 24 : 16;
} }
@ -663,6 +665,8 @@ EX void giantLandSwitch(cell *c, int d, cell *from) {
else if(arcm::in() && arcm::current.have_line) else if(arcm::in() && arcm::current.have_line)
c->wall = arcm::linespattern(c) ? waTrapdoor : waNone; c->wall = arcm::linespattern(c) ? waTrapdoor : waNone;
#endif #endif
else if(arb::in() && arb::current.have_line)
c->wall = arb::linespattern(c) ? waTrapdoor : waNone;
else if(euclid && !arcm::in()) { else if(euclid && !arcm::in()) {
auto co = euc2_coordinates(c); auto co = euc2_coordinates(c);
int y = co.second; int y = co.second;
@ -691,6 +695,8 @@ EX void giantLandSwitch(cell *c, int d, cell *from) {
else if(arcm::in() && arcm::current.have_line) else if(arcm::in() && arcm::current.have_line)
c->wall = arcm::linespattern(c) ? waVinePlant : waNone; c->wall = arcm::linespattern(c) ? waVinePlant : waNone;
#endif #endif
else if(arb::in() && arb::current.have_line)
c->wall = arb::linespattern(c) ? waVinePlant : waNone;
else if(nil) { else if(nil) {
if((c->master->emeraldval & 1) == 1) if((c->master->emeraldval & 1) == 1)
c->wall = waVinePlant; c->wall = waVinePlant;

View File

@ -1245,6 +1245,8 @@ EX int geosupport_football() {
if(arcm::in() /* PURE */) return arcm::current.support_football(); if(arcm::in() /* PURE */) return arcm::current.support_football();
#endif #endif
if(arb::in()) return arb::current.have_ph;
#if CAP_IRR #if CAP_IRR
if(IRREGULAR) return irr::bitruncations_performed ? 2 : 1; if(IRREGULAR) return irr::bitruncations_performed ? 2 : 1;
#endif #endif
@ -1269,7 +1271,7 @@ EX int pattern_threecolor(cell *c) {
return c->master->rval1; return c->master->rval1;
} }
#endif #endif
if(arb::in()) return 0; if(arb::in()) return arb::id_of(c->master) % 3;
if(IRREGULAR || bt::in()) return !pseudohept(c); if(IRREGULAR || bt::in()) return !pseudohept(c);
#if CAP_GP #if CAP_GP
if(S3 == 3 && !(S7&1) && gp_threecolor() == 1 && c->master->c7 != c) { if(S3 == 3 && !(S7&1) && gp_threecolor() == 1 && c->master->c7 != c) {
@ -1407,6 +1409,7 @@ EX bool pseudohept(cell *c) {
#if CAP_ARCM #if CAP_ARCM
if(arcm::in()) return arcm::pseudohept(c); if(arcm::in()) return arcm::pseudohept(c);
#endif #endif
if(arb::in()) return arb::pseudohept(c);
#if CAP_GP #if CAP_GP
if(GOLDBERG && gp_threecolor() == 2) if(GOLDBERG && gp_threecolor() == 2)
return gp::pseudohept_val(c) == 0; return gp::pseudohept_val(c) == 0;