HyperRogue  11.3d
game/visualization engine based on non-Euclidean geometry
Classes | Namespaces | Macros | Enumerations | Functions | Variables
pattern2.cpp File Reference

various functions computing the standings of individual cells with respect to various patterns More...

#include "hyper.h"

Classes

struct  hr::patterns::patterninfo
 
struct  hr::patterns::changeable_pattern_geometry
 
struct  hr::patterns::changeable_pattern
 
struct  hr::linepatterns::linepattern
 

Namespaces

 hr
 

Macros

#define REMAP_TEXTURE   texture::config.remap()
 
#define ALLCELLS(R)   [] (linepattern *lp) { auto& col = lp->color; for(auto& p: current_display->all_drawn_copies) for(auto& V: p.second) { cell *c = p.first; R } }
 
#define ATCENTER(T)   [] (linepattern *lp) { auto& col = lp->color; transmatrix V = gmatrix[cwt.at]; T}
 

Enumerations

enum  cpatterntype {
  cpFootball, cpThree, cpChess, cpSingle,
  cpSingleSym, cpOddEven, cpLarge, cpZebra,
  cpUnknown
}
 
enum  ePattern : char {
  PAT_NONE = 0, PAT_TYPES = 'T', PAT_ZEBRA = 'z', PAT_EMERALD = 'f',
  PAT_PALACE = 'p', PAT_FIELD = 'F', PAT_DOWN = 'H', PAT_COLORING = 'C',
  PAT_SIBLING = 'S', PAT_CHESS = 'c', PAT_SINGLETYPE = 't'
}
 

Functions

EX int hr::ctof (cell *c)
 
EX int hr::ctof012 (cell *c)
 
int hr::gp_threecolor ()
 
int hr::eupattern (cell *c)
 
int hr::eupattern4 (cell *c)
 
EX bool hr::ishept (cell *c)
 
EX bool hr::ishex1 (cell *c)
 
bool hr::ishex2 (cell *c)
 
int hr::chessvalue (cell *c)
 
EX int hr::emeraldval (heptagon *h)
 
EX int hr::emeraldval (cell *c)
 
unsigned hr::bitmajority (unsigned a, unsigned b, unsigned c)
 
int hr::eufifty (cell *c)
 
int hr::fiftyval (cell *c)
 
EX int hr::cdist50 (cell *c)
 
int hr::land50 (cell *c)
 
EX bool hr::polara50 (cell *c)
 
EX bool hr::polarb50 (cell *c)
 
EX int hr::fiftyval049 (heptagon *h)
 
EX int hr::fiftyval049 (cell *c)
 
EX int hr::fiftyval200 (cell *c)
 
int hr::dir_bitrunc457 (cell *c)
 
int hr::val46 (cell *c)
 
EX int hr::zebra40 (cell *c)
 
EX int hr::zebra3 (cell *c)
 
EX pair< int, bool > hr::fieldpattern::fieldval (cell *c)
 
EX int hr::fieldpattern::fieldval_uniq (cell *c)
 
EX int hr::fieldpattern::fieldval_uniq_rand (cell *c, int randval)
 
pair< int, int > hr::fieldpattern::subval (cell *c, int _subpathid=subpathid, int _subpathorder=subpathorder)
 
EX int hr::getHemisphere (heptagon *h, int which)
 
EX int hr::getHemisphere (cell *c, int which)
 
void hr::patterns::valSibling (cell *c, patterninfo &si, int sub, int pat)
 
EX int hr::patterns::downdir (cell *c, const cellfunction &cf)
 
void hr::patterns::applySym0123 (int &i, int sub)
 
void hr::patterns::applyAlt (patterninfo &si, int sub, int pat)
 
void hr::patterns::val46 (cell *c, patterninfo &si, int sub, int pat)
 
int hr::patterns::inr (int a, int b, int c)
 
void hr::patterns::val457 (cell *c, patterninfo &si, int sub)
 
EX void hr::patterns::val38 (cell *c, patterninfo &si, int sub, int pat)
 
void hr::patterns::valEuclid6 (cell *c, patterninfo &si, int sub)
 
void hr::patterns::valEuclid4 (cell *c, patterninfo &si, int sub)
 
void hr::patterns::val_all (cell *c, patterninfo &si, int sub, int pat)
 
void hr::patterns::val_warped (cell *c, patterninfo &si)
 
void hr::patterns::val_nopattern (cell *c, patterninfo &si, int sub)
 
void hr::patterns::val_threecolors (cell *c, patterninfo &si, int sub)
 
EX patterninfo hr::patterns::getpatterninfo (cell *c, ePattern pat, int sub)
 
patterninfo hr::patterns::getpatterninfo0 (cell *c)
 
EX bool hr::geosupport_chessboard ()
 
EX int hr::geosupport_threecolor ()
 
EX int hr::geosupport_football ()
 
EX int hr::pattern_threecolor (cell *c)
 
EX bool hr::pseudohept (cell *c)
 
EX bool hr::kraken_pseudohept (cell *c)
 
EX bool hr::warptype (cell *c)
 
color_t hr::random_landscape (cell *c, int mul, int div, int step, color_t base)
 
int hr::patterns::sevenval (cell *c)
 
color_t hr::patterns::nearer_map (cell *c)
 
color_t hr::patterns::furthest_map (cell *c, int reduce)
 
cld hr::patterns::compute_map_function (cell *c, int p, const string &formula)
 
EX int hr::patterns::generateCanvas (cell *c)
 
void hr::patterns::showPrePatternP (bool instant)
 
EX void hr::patterns::showPrePattern ()
 
EX void hr::patterns::showPrePatternNoninstant ()
 
EX void hr::patterns::showPattern ()
 
EX bool hr::patterns::compatible (cpatterntype oldp, cpatterntype newp)
 
void hr::patterns::showChangeablePatterns ()
 
EX void hr::patterns::computeCgroup ()
 
EX void hr::patterns::pushChangeablePatterns ()
 
EX bool hr::is_master (cell *c)
 
bool hr::linepatterns::always_available ()
 
bool hr::linepatterns::cheating ()
 
bool hr::linepatterns::stdhyp_only ()
 
color_t hr::linepatterns::lessalpha (color_t col, int m)
 
color_t hr::linepatterns::lessalphaif (color_t col, bool b)
 
color_t hr::linepatterns::lessalphaif (color_t col, bool b1, bool b2)
 
void hr::linepatterns::gridlinef (const transmatrix &V1, const hyperpoint &h1, const transmatrix &V2, const hyperpoint &h2, color_t col, int par)
 
void hr::linepatterns::gridlinef (const transmatrix &V, const hyperpoint &h1, const hyperpoint &h2, color_t col, int par)
 
EX void hr::linepatterns::clearAll ()
 
EX void hr::linepatterns::drawAll ()
 
EX void hr::linepatterns::showMenu ()
 
int hr::read_pattern_args ()
 

Variables

int hr::elhextable [28][3]
 
EX ePattern hr::patterns::whichPattern = PAT_NONE
 
EX int hr::patterns::subpattern_flags
 
EX map< char, colortable > hr::colortables
 
EX int hr::patterns::canvasback = linf[laCanvas].color >> 2
 
EX int hr::patterns::subcanvas
 
EX bool hr::patterns::displaycodes
 
EX char hr::patterns::whichShape = 0
 
EX char hr::patterns::whichCanvas = 0
 
EX bool hr::patterns::innerwalls
 
EX string hr::patterns::color_formula = "to01(rgb(x,y,z))"
 
map< cell *, color_t > hr::patterns::computed_nearer_map
 
map< cell *, color_t > hr::patterns::computed_furthest_map
 
EX hookset< int(cell *)> * hr::patterns::hooks_generate_canvas
 
vector< changeable_pattern > hr::patterns::cpatterns
 
EX cpatterntype hr::patterns::cgroup
 
EX cpatterntype hr::patterns::old_cgroup
 
linepattern hr::linepatterns::patDual ("dual grid", 0xFFFFFF00, always_available, ALLCELLS(forCellIdEx(c2, i, c) if(c2 > c) { gridlinef(V, C0, V *currentmap->adj(c, i), C0, col, 2+vid.linequality);}))
 
linepattern hr::linepatterns::patHepta ("heptagonal grid", 0x0000C000, always_available, ALLCELLS(forCellIdEx(c2, i, c) if(c2 > c) if(pseudohept(c)==pseudohept(c2)) gridlinef(V, C0, V *currentmap->adj(c, i), C0, col, 2+vid.linequality);))
 
linepattern hr::linepatterns::patRhomb ("rhombic tesselation", 0x0000C000, always_available, ALLCELLS(forCellIdEx(c2, i, c) if(c2 > c) if(pseudohept(c) !=pseudohept(c2)) gridlinef(V, C0, V *currentmap->adj(c, i), C0, col, 2+vid.linequality);))
 
linepattern hr::linepatterns::patTrihepta ("triheptagonal tesselation", 0x0000C000, always_available, ALLCELLS(if(pseudohept(c)) for(int t=0;t< c->type;t++) gridline(V, get_warp_corner(c, t%c->type), get_warp_corner(c,(t+1)%c->type), col, 1+vid.linequality);))
 
linepattern hr::linepatterns::patNormal ("normal tesselation", 0x0000C000, always_available, ALLCELLS(for(int t=0;t< c->type;t++) if(c->move(t) &&c->move(t)< c) gridline(V, get_corner_position(c, t), get_corner_position(c,(t+1)%c->type), col, 1+vid.linequality);))
 
linepattern hr::linepatterns::patBigTriangles ("big triangular grid", 0x00606000, always_available, ALLCELLS(if(is_master(c) &&!euclid) for(int i=0;i< S7;i++) if(c->master->move(i) &&c->master->move(i)< c->master) { gridlinef(V, C0, xspinpush0(-2 *M_PI *i/S7 - master_to_c7_angle(), cgi.tessf), col, 2+vid.linequality);}))
 
linepattern hr::linepatterns::patBigRings ("big triangles: rings", 0x00606000, cheating, ALLCELLS(if(is_master(c) &&!euclid) for(int i=0;i< S7;i++) if(c->master->move(i) &&c->master->move(i)< c->master &&c->master->move(i) ->dm4==c->master->dm4) gridlinef(V, C0, xspinpush0(-2 *M_PI *i/S7 - master_to_c7_angle(), cgi.tessf), col, 2+vid.linequality);))
 
linepattern hr::linepatterns::patTree ("underlying tree", 0x00d0d000, cheating, ALLCELLS(if(is_master(c)) { int dir=updir(c->master);if(dir==-1) continue;cell *c2=c->master->move(dir) ->c7;if(gmatrix.count(c2)) { if(S3 >=OINF) gridlinef(V, C0, Id, mid(tC0(V), tC0(V *currentmap->adj(c, dir))), col, 2+vid.linequality);else gridlinef(V, C0, V *master_relative(c, true) *currentmap->adj(c->master, dir), C0, col, 2+vid.linequality);} }))
 
linepattern hr::linepatterns::patAltTree ("circle/horocycle tree", 0xd000d000, cheating, ALLCELLS(if(is_master(c)) { int dir=updir_alt(c->master);if(dir==-1) continue;for(int i=0;i< S7;i++) if(c->master->move(i) &&c->master->move(i) ->alt==c->master->alt->move(0)) { cell *c2=c->master->move(i) ->c7;if(gmatrix.count(c2)) { if(S3 >=OINF) { gridlinef(V, C0, Id, mid(tC0(V), tC0(gmatrix[c2])), col, 2+vid.linequality);} else gridlinef(V, C0, V *master_relative(c, true) *currentmap->adj(c->master, i), C0, col, 2+vid.linequality);} } }))
 
linepattern hr::linepatterns::patHeawood ("seven-colorable torus", 0x40FF4000, [] { return euc::in(2, 6);}, ALLCELLS(if(c !=c->master->c7||patterns::sevenval(c)) break;gridline(V, C0, tC0(euc::eumove(gp::loc(-1,+3))), col, 3+vid.linequality);gridline(V, C0, tC0(euc::eumove(gp::loc(-3,+2))), col, 3+vid.linequality);gridline(V, C0, tC0(euc::eumove(gp::loc(-2, -1))), col, 3+vid.linequality);gridline(V, C0, tC0(euc::eumove(gp::loc(+1, -3))), col, 3+vid.linequality);gridline(V, C0, tC0(euc::eumove(gp::loc(+3, -2))), col, 3+vid.linequality);gridline(V, C0, tC0(euc::eumove(gp::loc(+2,+1))), col, 3+vid.linequality);))
 
linepattern hr::linepatterns::patZebraTriangles ("zebra triangles", 0x40FF4000, stdhyp_only, ALLCELLS(if(zebra40(c)/4==10) { bool all=true;transmatrix tri[3];for(int i=0;i< 3;i++) tri[i]=V *currentmap->adj(c, i *2);if(all) for(int i=0;i< 3;i++) gridline(tri[i], C0, tri[(i+1)%3], C0, col, 3+vid.linequality);}))
 
linepattern hr::linepatterns::patZebraLines ("zebra lines", 0xFF000000, stdhyp_only, ALLCELLS(if(!pseudohept(c)) for(int i=0;i< c->type;i+=2) { cell *c2=createMov(c, i);int fv1=zebra40(c);if(fv1/4==4||fv1/4==6||fv1/4==5||fv1/4==10) fv1 ^=2;int fv2=zebra40(c2);if(fv2/4==4||fv2/4==6||fv2/4==5||fv2/4==10) fv2 ^=2;if((fv1 &1)==(fv2 &1)) continue;double x=cgi.hexhexdist/2;gridlinef(V, ddspin(c, i,-M_PI/S3) *xpush0(x), ddspin(c, i, M_PI/S3) *xpush0(x), col, 1+vid.linequality);}))
 
linepattern hr::linepatterns::patGoldbergTree ("Goldberg tree", 0x8438A400, [] { return GOLDBERG;}, ALLCELLS(if(c->master->c7 !=c) gridlinef(V, C0, V *currentmap->adj(c, 0), C0, darkena(backcolor ^ 0xFFFFFF, 0, col), 2+vid.linequality);))
 
linepattern hr::linepatterns::patIrregularMaster ("irregular master", 0x8438A400, [] { return IRREGULAR;}, ALLCELLS(if(c->master->c7 !=c) if(gmatrix.count(c->master->c7)) gridlinef(V, C0, V *master_relative(c, true), C0, darkena(backcolor ^ 0xFFFFFF, 0, col), 2+vid.linequality);))
 
linepattern hr::linepatterns::patVine ("vineyard pattern", 0x8438A400, stdhyp_only, ALLCELLS(int p=emeraldval(c);double hdist=hdist0(cgi.heptmove[0] *cgi.heptmove[2] *C0);if(pseudohept(c) &&(p/4==10||p/4==8)) for(int i=0;i< S7;i++) if(c->move(i) &&emeraldval(c->move(i))==p-4) { gridlinef(V, C0, tC0(cgi.heptmove[i]), col, 2+vid.linequality);gridlinef(V, C0, xspinpush0(-i *2 *M_PI/S7, -hdist/2), col, 2+vid.linequality);}))
 
linepattern hr::linepatterns::patPalacelike ("firewall lines", 0xFF400000, stdhyp_only, ALLCELLS(if(pseudohept(c)) for(int i=0;i< 7;i++) gridlinef(V, ddspin(c, i, M_PI *5/7) *xpush0(cgi.tessf/2), ddspin(c, i, M_PI *9/7) *xpush0(cgi.tessf/2), col, 1+vid.linequality);))
 
linepattern hr::linepatterns::patPalace ("firewall lines: Palace", 0xFFD50000, stdhyp_only, ALLCELLS(bool a=polarb50(c);if(pseudohept(c)) for(int i=0;i< 7;i++) { cell *c1=createMov(c,(i+3) % 7);cell *c2=createMov(c,(i+4) % 7);if(polarb50(c1) !=a &&polarb50(c2) !=a) gridlinef(V, ddspin(c, i, M_PI *5/7) *xpush0(cgi.tessf/2), ddspin(c, i, M_PI *9/7) *xpush0(cgi.tessf/2), col, 1+vid.linequality);}))
 
linepattern hr::linepatterns::patGoldbergSep ("Goldberg", 0xFFFF0000, [] { return GOLDBERG;}, ALLCELLS(forCellIdEx(c2, i, c) if(c2->master !=c->master) gridlinef(V, C0, V *currentmap->adj(c, i), C0, col, 1+vid.linequality);))
 
linepattern hr::linepatterns::patArcm ("Archimedean", 0xFFFF0000, [] { return arcm::in();}, ALLCELLS(if(!pseudohept(c)) forCellIdEx(c2, i, c) if(c< c2 &&!pseudohept(c2)) gridlinef(V, C0, V *currentmap->adj(c, i), C0, col, 1+vid.linequality);))
 
linepattern hr::linepatterns::patPower ("firewall lines: Power", 0xFFFF0000, stdhyp_only, ALLCELLS(int a=emeraldval(c);if(pseudohept(c) &&a/4==8) for(int i=0;i< 7;i++) { heptagon *h1=c->master->modmove(i+1);heptagon *h2=c->master->modmove(i-1);if(!h1||!h2) continue;if(emeraldval(h1->c7)/4==8 &&emeraldval(h2->c7)/4==8) gridlinef(V, ddspin(c, i, M_PI *5/7) *xpush0(cgi.tessf/2), ddspin(c, i, M_PI *9/7) *xpush0(cgi.tessf/2), col, 1+vid.linequality);}))
 
linepattern hr::linepatterns::patHorocycles ("horocycles", 0xd060d000, cheating, ALLCELLS(if(c->master->alt) { int d=celldistAlt(c);forCellIdEx(c2, i, c) if(c2 > c &&c2->master->alt &&celldistAlt(c2)==d) gridlinef(V, C0, V *currentmap->adj(c, i), C0, darkena(backcolor ^ 0xFFFFFF, 0, col), 2+vid.linequality);}))
 
linepattern hr::linepatterns::patTriRings ("triangle grid: rings", 0xFFFFFF00, always_available, ALLCELLS(forCellIdEx(c2, i, c) { if(S3==4) c2=(cellwalker(c, i)+wstep+1).cpeek();if(c2 > c) if(curr_dist(c)==curr_dist(c2)) gridlinef(V, C0, V *currentmap->adj(c, i), C0, col, 2+vid.linequality);}))
 
linepattern hr::linepatterns::patTriTree ("triangle grid: tree edges", 0xFFFFFF00, always_available, ALLCELLS(cell *parent=ts::right_parent(c, curr_dist);if(gmatrix.count(parent)) gridlinef(V, C0, V *currentmap->adj(c, neighborId(c, parent)), C0, col, 2+vid.linequality);))
 
linepattern hr::linepatterns::patTriOther ("triangle grid: other edges", 0xFFFFFF00, always_available, ALLCELLS(cell *parent=ts::right_parent(c, curr_dist);forCellIdEx(c2, i, c) if(curr_dist(c2)< curr_dist(c) &&c2 !=parent) gridlinef(V, C0, V *currentmap->adj(c, i), C0, col, 2+vid.linequality);))
 
linepattern hr::linepatterns::patCircles ("circles", 0xFFFFFF00, always_available, ATCENTER(for(int i=15;i<=180;i+=15) { for(int j=0;j< 360;j+=15) { for(int k=0;k<=15;k++) curvepoint(xspinpush0((j+k) *degree, i *degree));queuecurve(col, 0, PPR::LINE).V=V;} }))
 
linepattern hr::linepatterns::patRadii ("radii", 0xFFFFFF00, always_available, ATCENTER(for(int i=0;i< 360;i+=15) { for(int j=0;j< 180;j+=15) { for(int k=0;k<=15;k++) curvepoint(xspinpush0(i *degree,(j+k) *degree));queuecurve(col, 0, PPR::LINE).V=V;} }))
 
linepattern hr::linepatterns::patMeridians ("meridians", 0xFFFFFF00, always_available, ATCENTER(for(int j=-180;j<=180;j+=15) { for(int i=-90;i< 90;i+=15) { for(int k=0;k<=15;k++) curvepoint(V *xpush(j *degree) *ypush0((i+k) *degree));queuecurve(col, 0, PPR::LINE).V=V;} }))
 
linepattern hr::linepatterns::patParallels ("parallels", 0xFFFFFF00, always_available, ATCENTER(for(int i=-90;i<=90;i+=15) { for(int j=-180;j< 180;j+=15) { for(int k=0;k<=15;k++) curvepoint(V *xpush((j+k) *degree) *ypush0(i *degree));queuecurve(col, 0, PPR::LINE).V=V;} }))
 
linepattern hr::linepatterns::patSublines ("sub-lines", 0xFFFFFF00, arb::in, ALLCELLS(int i=arb::id_of(c->master);auto &sh=arb::current.shapes[i];for(auto p:sh.sublines) gridlinef(V, sh.vertices[p.first], sh.vertices[p.second], col, 2+vid.linequality);))
 
EX vector< linepattern * > hr::linepatterns::patterns
 
EX ld hr::linepatterns::width = 1
 
int hr::linepatterns::numpat = 0
 
bool hr::linepatterns::indiv
 
auto hr::ah_pattern = addHook(hooks_args, 0, read_pattern_args) + addHook(clearmemory, 100, [] { patterns::computed_nearer_map.clear(); patterns::computed_furthest_map.clear(); })
 

Detailed Description

various functions computing the standings of individual cells with respect to various patterns

Patterns include simple ones (hexagon or heptagon, three-colorings, Chessboard) as well as more complex ones (Emerald, Palace, Field Pattern)

Variable Documentation

◆ patterns

EX vector<linepattern*> hr::linepatterns::patterns
Initial value:
= {
&patDual, &patHepta, &patRhomb, &patTrihepta, &patNormal, &patBigTriangles,
&patTree, &patAltTree, &patZebraTriangles, &patZebraLines,
&patVine, &patPalacelike, &patPalace, &patPower, &patHorocycles,
&patTriRings, &patTriTree, &patTriOther,
&patGoldbergTree, &patIrregularMaster, &patGoldbergSep, &patHeawood, &patArcm,
&patCircles, &patRadii, &patMeridians, &patParallels, &patSublines
}