-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmooreconfgen.py
More file actions
executable file
·44 lines (40 loc) · 1.52 KB
/
mooreconfgen.py
File metadata and controls
executable file
·44 lines (40 loc) · 1.52 KB
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
#!/usr/bin/env python3
import numpy as np
# 0,
# 1c, 1e, 2c, 2e, 2k, 2a, 2i,
# 2n, 3c, 3e, 3k, 3a, 3i, 3n,
# 3y, 3q, 3j, 3r, 4c, 4e, 4k,
# 4a, 4i, 4n, 4y, 4q, 4j, 4r,
# 4t, 4w, 4z, 5c, 5e, 5k, 5a,
# 5i, 5n, 5y, 5q, 5j, 5r, 6c,
# 6e, 6k, 6a, 6i, 6n, 7c, 7e,
# 8
# B0 required = 1
# B0 forbidden = -1
# S0 required = 2
# S0 forbidden = -2
# B1c required = 3
# B1c forbidden = -3
# S1c required = 4
# S1c forbidden = -4, etc.
arrays = ("00000000",
"10000000", "01000000",
"10100000", "01010000", "10001000", "11000000", "00011000", "10000001",
"10100100", "01011000", "10001010", "11010000", "11100000", "10110000", "10100010", "11000001", "11001000", "11000010",
"10100101", "01011010", "10110010", "11110000", "10111000", "11100100", "10101100", "11010001", "11001010", "11011000", "11100010", "11001001", "11000011",
"01011011", "10100111", "01110101", "00101111", "00011111", "01001111", "01011101", "00111110", "00110111", "00111101",
"01011111", "10101111", "01110111", "00111111", "11100111", "01111110",
"01111111", "10111111",
"11111111")
table = [-1] * 256
for (k, neigh) in enumerate(arrays):
b = [int(c) for c in neigh]
A = np.array([[b[0], b[1], b[2]],
[b[3], 0, b[4]],
[b[5], b[6], b[7]]])
for m in range(4):
rA = np.rot90(A, m).flatten() @ (128, 64, 32, 16, 0, 8, 4, 2, 1)
table[rA] = k
rA = np.rot90(A, m).T.flatten() @ (128, 64, 32, 16, 0, 8, 4, 2, 1)
table[rA] = k
print(table)