File: macbeath.cpp

package info (click to toggle)
hyperrogue 12.1q-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 73,972 kB
  • sloc: cpp: 166,609; makefile: 145; sh: 10
file content (132 lines) | stat: -rw-r--r-- 2,935 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// Fricke-Macbeath Surface generator
// Copyright (C) 2018 Zeno Rogue, see 'hyper.cpp' for details

#include <stdio.h>
#include <vector>
#include <array>
#include <map>

using namespace std;

int isize(const auto x) { return x.size(); }

int mul(int a, int b) { 
  int p = 0;
  for(int i=0; i<3; i++) if((a>>i)&1)
  for(int j=0; j<3; j++) if((b>>j)&1)
    p ^= (1<<(i+j));
  
  for(int z=4; z>=0; z--)
    if(p&(8<<z)) p ^= (11<<z);
    
  return p;
  }

int multable[8][8];

int elements = 0;

vector<array<int, 4>> psl_elements;

int multable_psl[504][504];

map<array<int, 4>, int> back;

int mpow(int a, int n) {
  int z = a;
  while(n > 1) z = multable_psl[a][z], n--;
  return z;
  }

int inset[504];

int main() {
  for(int a=0; a<8; a++) {
    for(int b=0; b<8; b++) printf("%d ", mul(a, b));
    printf("\n");
    }

  for(int a=0; a<8; a++)
    for(int b=0; b<8; b++) 
      multable[a][b] = mul(a, b);

  for(int a=0; a<8; a++)
    for(int b=0; b<8; b++) 
      for(int c=0; c<8; c++)
        for(int d=0; d<8; d++) 
          if((multable[a][d] ^ multable[b][c]) == 1) {
            array<int, 4> arr = { a, b, c, d};
            psl_elements.emplace_back(arr);
            }
          
  printf("elements = %d\n", isize(psl_elements));

  for(int a=0; a<504; a++) back[psl_elements[a]] = a;
  
  for(int a=0; a<504; a++)
  for(int b=0; b<504; b++) {
    auto pa = psl_elements[a];
    auto pb = psl_elements[b];
    array<int, 4> pc;
    for(int s=0; s<4; s++) {
      int s0 = s&2;
      int s1 = s&1;
      pc[s] = (multable[pa[s0]][pb[s1]] ^ multable[pa[s0^1]][pb[s1^2]]);
      }
    multable_psl[a][b] = back[pc];
    }

  int id;
  
  for(int a=0; a<504; a++)
    if(multable_psl[a][a] == a) id = a;
  
  printf("id = %d\n", id);

  int xid = 0;

  for(int R=0; R<504; R++)
  for(int P=0; P<504; P++) {
    if(multable_psl[P][P] != id) continue;
    if(mpow(multable_psl[R][P], 3) != id) continue;
    if(mpow(R, 7) != id) continue;
    xid++;
    vector<int> allels = {id};
    inset[id] = xid;
    for(int i=0; i<isize(allels); i++) {
      for(int m: {P, R}) {
        int im = allels[i];
        int a = multable_psl[im][m];
        // printf("%d x %d = %d\n", im, m, a);
        if(inset[a] != xid) inset[a] = xid, allels.push_back(a);
        }
      }
    printf("R = %d P = %d count = %d\n", R, P, isize(allels));

    array<int, 504> cellid;
    array<int, 504> bycellid;

    for(int a=0; a<504; a++) cellid[a] = 0;

    int ncell = 0;
    for(int a=0; a<504; a++) if(cellid[a] == 0) {
      int b = a;
      for(int s=0; s<7; s++) cellid[b] = ncell + s, bycellid[ncell + s] = b, b = multable_psl[b][R];
      ncell += 7;
      }
    
    printf("ncell = %d\n", ncell);

    for(int a=0; a<72; a++) {
      printf("/* %03d */ ", a);
      for(int b=0; b<7; b++) {
        printf("%d, ", cellid[multable_psl[bycellid[7*a+b]][P]]);
        }
      printf("\n");
      }

    return 0;
    }

  return 0;
  }