// HyperRogue patterns // Copyright (C) 2011-2016 Zeno Rogue, see 'hyper.cpp' for details // === EMERALD PATTERN === // rules for the emeraldvalues of heptagons. int emerald_heptagon(int parent, int dir) { if(a46) return (parent+dir)&1; if(S7 == 8 && dir > 3) dir--; // no emeraldgen here if(parent == 0) return 0; #define RULE(t1,s1,d,t2,s2) \ if(parent == t1*8+s1 && dir == d) return t2*8+s2; RULE(8,0,3,12,4) RULE(8,0,4,12,0) RULE(8,0,5,42,0) RULE(8,1,3,40,0) RULE(8,1,4,12,4) RULE(8,1,5,12,0) RULE(8,2,3,34,0) RULE(8,2,4,40,0) RULE(8,2,5,12,4) RULE(8,3,3,10,0) RULE(8,3,4,34,0) RULE(8,3,5,40,0) RULE(8,4,3,32,0) RULE(8,4,4,10,0) RULE(8,4,5,34,0) RULE(8,5,3,42,0) RULE(8,5,4,32,0) RULE(8,5,5,10,0) RULE(8,6,3,12,0) RULE(8,6,4,42,0) RULE(8,6,5,32,0) RULE(9,0,3,13,4) RULE(9,0,4,13,0) RULE(9,0,5,43,0) RULE(9,1,3,41,0) RULE(9,1,4,13,4) RULE(9,1,5,13,0) RULE(9,2,3,35,0) RULE(9,2,4,41,0) RULE(9,2,5,13,4) RULE(9,3,3,11,0) RULE(9,3,4,35,0) RULE(9,3,5,41,0) RULE(9,4,3,33,0) RULE(9,4,4,11,0) RULE(9,4,5,35,0) RULE(9,5,3,43,0) RULE(9,5,4,33,0) RULE(9,5,5,11,0) RULE(9,6,3,13,0) RULE(9,6,4,43,0) RULE(9,6,5,33,0) RULE(10,0,3,14,4) RULE(10,0,4,14,0) RULE(10,0,5,40,3) RULE(10,1,3,42,4) RULE(10,1,4,14,4) RULE(10,1,5,14,0) RULE(10,2,3,32,1) RULE(10,2,4,42,4) RULE(10,2,5,14,4) RULE(10,3,3,8,0) RULE(10,3,4,32,1) RULE(10,3,5,42,4) RULE(10,4,3,34,6) RULE(10,4,4,8,0) RULE(10,4,5,32,1) RULE(10,5,3,40,3) RULE(10,5,4,34,6) RULE(10,5,5,8,0) RULE(10,6,3,14,0) RULE(10,6,4,40,3) RULE(10,6,5,34,6) RULE(11,0,3,15,4) RULE(11,0,4,15,0) RULE(11,0,5,41,3) RULE(11,1,3,43,4) RULE(11,1,4,15,4) RULE(11,1,5,15,0) RULE(11,2,3,33,1) RULE(11,2,4,43,4) RULE(11,2,5,15,4) RULE(11,3,3,9,0) RULE(11,3,4,33,1) RULE(11,3,5,43,4) RULE(11,4,3,35,6) RULE(11,4,4,9,0) RULE(11,4,5,33,1) RULE(11,5,3,41,3) RULE(11,5,4,35,6) RULE(11,5,5,9,0) RULE(11,6,3,15,0) RULE(11,6,4,41,3) RULE(11,6,5,35,6) RULE(12,0,3,8,4) RULE(12,0,4,40,1) RULE(12,0,5,14,2) RULE(12,1,3,12,6) RULE(12,1,4,8,4) RULE(12,1,5,40,1) RULE(12,2,0,14,2) RULE(12,2,1,42,6) RULE(12,2,2,8,3) RULE(12,2,3,12,5) RULE(12,2,4,12,6) RULE(12,2,5,8,4) RULE(12,2,6,40,1) RULE(12,3,3,8,3) RULE(12,3,4,12,5) RULE(12,3,5,12,6) RULE(12,4,3,42,6) RULE(12,4,4,8,3) RULE(12,4,5,12,5) RULE(12,5,3,14,2) RULE(12,5,4,42,6) RULE(12,5,5,8,3) RULE(12,6,3,40,1) RULE(12,6,4,14,2) RULE(12,6,5,42,6) RULE(13,0,3,9,4) RULE(13,0,4,41,1) RULE(13,0,5,15,2) RULE(13,1,3,13,6) RULE(13,1,4,9,4) RULE(13,1,5,41,1) RULE(13,2,3,13,5) RULE(13,2,4,13,6) RULE(13,2,5,9,4) RULE(13,3,3,9,3) RULE(13,3,4,13,5) RULE(13,3,5,13,6) RULE(13,4,3,43,6) RULE(13,4,4,9,3) RULE(13,4,5,13,5) RULE(13,5,3,15,2) RULE(13,5,4,43,6) RULE(13,5,5,9,3) RULE(13,6,3,41,1) RULE(13,6,4,15,2) RULE(13,6,5,43,6) RULE(14,0,3,10,4) RULE(14,0,4,42,5) RULE(14,0,5,12,2) RULE(14,1,3,14,6) RULE(14,1,4,10,4) RULE(14,1,5,42,5) RULE(14,2,0,12,2) RULE(14,2,3,14,5) RULE(14,2,4,14,6) RULE(14,2,5,10,4) RULE(14,3,3,10,3) RULE(14,3,4,14,5) RULE(14,3,5,14,6) RULE(14,4,3,40,2) RULE(14,4,4,10,3) RULE(14,4,5,14,5) RULE(14,5,3,12,2) RULE(14,5,4,40,2) RULE(14,5,5,10,3) RULE(14,6,3,42,5) RULE(14,6,4,12,2) RULE(14,6,5,40,2) RULE(15,0,3,11,4) RULE(15,0,4,43,5) RULE(15,0,5,13,2) RULE(15,1,3,15,6) RULE(15,1,4,11,4) RULE(15,1,5,43,5) RULE(15,2,3,15,5) RULE(15,2,4,15,6) RULE(15,2,5,11,4) RULE(15,3,3,11,3) RULE(15,3,4,15,5) RULE(15,3,5,15,6) RULE(15,4,3,41,2) RULE(15,4,4,11,3) RULE(15,4,5,15,5) RULE(15,5,3,13,2) RULE(15,5,4,41,2) RULE(15,5,5,11,3) RULE(15,6,3,43,5) RULE(15,6,4,13,2) RULE(15,6,5,41,2) RULE(32,0,3,43,2) RULE(32,0,4,33,3) RULE(32,0,5,42,3) RULE(32,1,3,33,5) RULE(32,1,4,43,2) RULE(32,1,5,33,3) RULE(32,2,3,42,1) RULE(32,2,4,33,5) RULE(32,2,5,43,2) RULE(32,3,3,8,1) RULE(32,3,4,42,1) RULE(32,3,5,33,5) RULE(32,4,3,10,6) RULE(32,4,4,8,1) RULE(32,4,5,42,1) RULE(32,5,3,42,3) RULE(32,5,4,10,6) RULE(32,5,5,8,1) RULE(32,6,3,33,3) RULE(32,6,4,42,3) RULE(32,6,5,10,6) RULE(33,0,3,42,2) RULE(33,0,4,32,3) RULE(33,0,5,43,3) RULE(33,1,3,32,5) RULE(33,1,4,42,2) RULE(33,1,5,32,3) RULE(33,2,3,43,1) RULE(33,2,4,32,5) RULE(33,2,5,42,2) RULE(33,3,3,9,1) RULE(33,3,4,43,1) RULE(33,3,5,32,5) RULE(33,4,3,11,6) RULE(33,4,4,9,1) RULE(33,4,5,43,1) RULE(33,5,3,43,3) RULE(33,5,4,11,6) RULE(33,5,5,9,1) RULE(33,6,3,32,3) RULE(33,6,4,43,3) RULE(33,6,5,11,6) RULE(34,0,3,35,4) RULE(34,0,4,41,5) RULE(34,0,5,35,2) RULE(34,1,3,40,4) RULE(34,1,4,35,4) RULE(34,1,5,41,5) RULE(34,2,3,10,1) RULE(34,2,4,40,4) RULE(34,2,5,35,4) RULE(34,3,3,8,6) RULE(34,3,4,10,1) RULE(34,3,5,40,4) RULE(34,4,3,40,6) RULE(34,4,4,8,6) RULE(34,4,5,10,1) RULE(34,5,3,35,2) RULE(34,5,4,40,6) RULE(34,5,5,8,6) RULE(34,6,3,41,5) RULE(34,6,4,35,2) RULE(34,6,5,40,6) RULE(35,0,3,34,4) RULE(35,0,4,40,5) RULE(35,0,5,34,2) RULE(35,1,3,41,4) RULE(35,1,4,34,4) RULE(35,1,5,40,5) RULE(35,2,3,11,1) RULE(35,2,4,41,4) RULE(35,2,5,34,4) RULE(35,3,3,9,6) RULE(35,3,4,11,1) RULE(35,3,5,41,4) RULE(35,4,3,41,6) RULE(35,4,4,9,6) RULE(35,4,5,11,1) RULE(35,5,3,34,2) RULE(35,5,4,41,6) RULE(35,5,5,9,6) RULE(35,6,3,40,5) RULE(35,6,4,34,2) RULE(35,6,5,41,6) RULE(40,0,3,34,5) RULE(40,0,4,10,2) RULE(40,0,5,14,1) RULE(40,1,3,35,3) RULE(40,1,4,34,5) RULE(40,1,5,10,2) RULE(40,2,3,34,1) RULE(40,2,4,35,3) RULE(40,2,5,34,5) RULE(40,3,3,8,5) RULE(40,3,4,34,1) RULE(40,3,5,35,3) RULE(40,4,3,12,3) RULE(40,4,4,8,5) RULE(40,4,5,34,1) RULE(40,5,3,14,1) RULE(40,5,4,12,3) RULE(40,5,5,8,5) RULE(40,6,3,10,2) RULE(40,6,4,14,1) RULE(40,6,5,12,3) RULE(41,0,3,35,5) RULE(41,0,4,11,2) RULE(41,0,5,15,1) RULE(41,1,3,34,3) RULE(41,1,4,35,5) RULE(41,1,5,11,2) RULE(41,2,3,35,1) RULE(41,2,4,34,3) RULE(41,2,5,35,5) RULE(41,3,3,9,5) RULE(41,3,4,35,1) RULE(41,3,5,34,3) RULE(41,4,3,13,3) RULE(41,4,4,9,5) RULE(41,4,5,35,1) RULE(41,5,3,15,1) RULE(41,5,4,13,3) RULE(41,5,5,9,5) RULE(41,6,3,11,2) RULE(41,6,4,15,1) RULE(41,6,5,13,3) RULE(42,0,3,10,5) RULE(42,0,4,32,2) RULE(42,0,5,33,4) RULE(42,1,3,14,3) RULE(42,1,4,10,5) RULE(42,1,5,32,2) RULE(42,2,3,12,1) RULE(42,2,4,14,3) RULE(42,2,5,10,5) RULE(42,3,3,8,2) RULE(42,3,4,12,1) RULE(42,3,5,14,3) RULE(42,4,3,32,6) RULE(42,4,4,8,2) RULE(42,4,5,12,1) RULE(42,5,3,33,4) RULE(42,5,4,32,6) RULE(42,5,5,8,2) RULE(42,6,3,32,2) RULE(42,6,4,33,4) RULE(42,6,5,32,6) RULE(43,0,3,11,5) RULE(43,0,4,33,2) RULE(43,0,5,32,4) RULE(43,1,3,15,3) RULE(43,1,4,11,5) RULE(43,1,5,33,2) RULE(43,2,3,13,1) RULE(43,2,4,15,3) RULE(43,2,5,11,5) RULE(43,3,3,9,2) RULE(43,3,4,13,1) RULE(43,3,5,15,3) RULE(43,4,3,33,6) RULE(43,4,4,9,2) RULE(43,4,5,13,1) RULE(43,5,3,32,4) RULE(43,5,4,33,6) RULE(43,5,5,9,2) RULE(43,6,3,33,2) RULE(43,6,4,32,4) RULE(43,6,5,33,6) #undef RULE if(weirdhyperbolic) return 0; printf("HEPTAGONAL RULE MISSING for (%d,%d)\n", parent,dir); exit(1); } // calculate the emeraldvalue of a hexagonal cell, // based on the emeraldvalues of the neighbor heptacells. int emerald_hexagon(int a, int b, int c) { // pick the lexicographically smallest representation of the cycle if(b <= a || c 3) d--; return fiftytable[0][d]; } int nextfiftyval(int par, int gpar, int d) { if(S7 == 8 && d > 3) d--; for(int i=0; i<7; i++) if(fiftytable[par][i] == gpar) return fiftytable[par][(i+d)%7]; if(weirdhyperbolic) return 0; printf("fifty pattern error!\n"); exit(1); } int land50(int x) { return x&7; } bool polara50(int x) { return x&8; } bool polarb50(int x) { return x&16; } int cdist50(int x) { x /= 32; if(x == 0) return 0; if(x < 8) return 2; return 3; } int zebratable[12][7] = { {50, 70, 60, 120, 80, 100, 64}, {40, 65, 72, 130, 90, 110, 76}, {45, 71, 56, 41, 101, 140, 126}, {46, 51, 111, 150, 136, 55, 66}, {43, 121, 145, 103, 93, 114, 106}, {53, 131, 155, 113, 83, 104, 116}, {42, 81, 115, 92, 84, 146, 63}, {52, 91, 105, 82, 94, 156, 75}, {44, 61, 141, 134, 152, 144, 86}, {54, 73, 151, 124, 142, 154, 96}, {62, 102, 85, 122, 153, 133, 125}, {74, 112, 95, 132, 143, 123, 135} }; int zebratable6[28][3] = { {4,10,6}, {5,11,7}, {4,6,12}, {5,7,13}, {8,14,10}, {9,15,11}, {4,8,10}, {5,9,11}, {6,14,12}, {7,15,13}, {8,12,14}, {9,13,15}, {4,7,6}, {5,6,7}, {4,6,5}, {4,5,7}, {8,11,10}, {9,10,11}, {8,10,9}, {8,9,11}, {12,15,14}, {13,14,15}, {12,14,13}, {12,13,15}, {6,10,14}, {7,11,15}, {4,12,8}, {5,13,9} }; // rules for the emeraldvalues of heptagons. int zebra_heptagon(int parent, int dir) { if(S3 == 4) { int mm = (parent % 10 + S7 - dir) % S7; int mv = parent / 10; // whichbright: d&1 if(S7 == 5) switch(mm) { case 0: return 10 * (mv^1); case 1: return 10 * (mv^2) + 4; case 2: return 10 * (mv^4) + 3; case 3: return 10 * (mv^4) + 2; case 4: return 10 * (mv^2) + 1; } if(S7 == 7) switch(mm) { case 0: return 10 * (mv^2); case 1: return 10 * (mv^1) + 6; case 2: return 10 * (mv^2) + 5; case 3: return 10 * (mv^4) + 4; case 4: return 10 * (mv^4) + 3; case 5: return 10 * (mv^2) + 2; case 6: return 10 * (mv^1) + 1; } if(S7 == 6) switch(mm) { case 0: return 10 * (mv^2); case 1: return 10 * (mv^1) + 5; case 2: return 10 * (mv^2) + 4; case 3: return 10 * (mv^1) + 3; case 4: return 10 * (mv^2) + 2; case 5: return 10 * (mv^1) + 1; } } if(S7 == 8 && dir > 3) dir--; return zebratable[parent/10-4][(70+dir-(parent%10))%7]; }