-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRule:Wireworld++
142 lines (127 loc) · 3.72 KB
/
Rule:Wireworld++
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
133
134
135
136
137
138
139
140
141
142
@RULE Wireworld++
Rule by Vladislav Gladkikh and Alexandr Nigay
Wireworld++ is like 2 WireWorld's mashed together. There are 2 separate WireWorlds inside Wireworld++ - the 'strong' world (states 1, 2, 3) and the 'weak' world (states 4, 5, 6).
Independently, any circuit built entirely out of cells from only one world behave identicaly to regular WireWorld - since it takes 1 or 2 adjacent 'weak' heads (state 4) to turn a weak wire (state 6) into a weak head, and the same goes for the strong wire (state 3) and its heads (state 1).
The power of Wireworld++ arises when one puts the two worlds together. A strong wire will turn to a strong head when exactly two of its neighbors are weak heads, while a weak wire will turn to a weak head if exactly one of its neighbors is a strong head.
With this, it is very easy to construct very small AND and XOR gates. To make an AND gate, connect two weak wires (inputs) to one strong wire (output). To make an XOR gate, connect two strong wires to a weak wire.
Fore more information, read this article:
https://wpmedia.wolfram.com/uploads/sites/13/2018/07/27-1-2.pdf
---------------------------------------------------------
The following script was used with the standard script 'make-ruletree.py' to generate the TREE section of this file:
name = "Wireworld++"
n_states = 7
n_neighbors = 8
def transition_function(a):
nw, ne, sw, se, n, w, e, s, c = a #unpack
neigh = n, ne, e, se, s, sw, w, nw #repack
BG=0;SH=1;ST=2;SW=3;WH=4;WT=5;WW=6
shc = 0
whc = 0
for n in neigh:
if n == SH: shc += 1
if n == WH: whc += 1
if c==BG: return BG
elif c==SH: return ST
elif c==ST: return SW
elif c==WH: return WT
elif c==WT: return WW
elif c==SW:
if shc==1 or shc==2 or whc==2: return SH
else: return SW
elif c==WW:
if whc==1 or whc==2 or shc==1: return WH
else: return WW
else: raise ValueError("invalid state: " + str(c))
@TREE
num_states=7
num_neighbors=8
num_nodes=81
1 0 2 3 3 5 6 6
1 0 2 3 1 5 6 4
1 0 2 3 3 5 6 4
2 0 1 0 0 2 0 0
1 0 2 3 1 5 6 6
2 1 4 1 1 1 1 1
2 2 1 2 2 1 2 2
3 3 5 3 3 6 3 3
2 4 0 4 4 1 4 4
2 1 1 1 1 1 1 1
3 5 8 5 5 9 5 5
2 1 1 1 1 0 1 1
3 6 9 6 6 11 6 6
4 7 10 7 7 12 7 7
2 0 0 0 0 2 0 0
2 1 2 1 1 1 1 1
3 8 14 8 8 15 8 8
3 9 15 9 9 9 9 9
4 10 16 10 10 17 10 10
2 0 1 0 0 0 0 0
3 11 9 11 11 19 11 11
4 12 17 12 12 20 12 12
5 13 18 13 13 21 13 13
2 2 2 2 2 1 2 2
3 14 14 14 14 23 14 14
2 1 1 1 1 4 1 1
3 15 23 15 15 25 15 15
4 16 24 16 16 26 16 16
3 9 25 9 9 5 9 9
4 17 26 17 17 28 17 17
5 18 27 18 18 29 18 18
3 19 5 19 19 19 19 19
4 20 28 20 20 31 20 20
5 21 29 21 21 32 21 21
6 22 30 22 22 33 22 22
3 23 23 23 23 11 23 23
4 24 24 24 24 35 24 24
2 4 0 4 4 4 4 4
3 25 11 25 25 37 25 25
4 26 35 26 26 38 26 26
5 27 36 27 27 39 27 27
3 5 37 5 5 5 5 5
4 28 38 28 28 41 28 28
5 29 39 29 29 42 29 29
6 30 40 30 30 43 30 30
4 31 41 31 31 31 31 31
5 32 42 32 32 45 32 32
6 33 43 33 33 46 33 33
7 34 44 34 34 47 34 34
2 0 0 0 0 0 0 0
3 11 11 11 11 49 11 11
4 35 35 35 35 50 35 35
5 36 36 36 36 51 36 36
3 37 49 37 37 37 37 37
4 38 50 38 38 53 38 38
5 39 51 39 39 54 39 39
6 40 52 40 40 55 40 40
4 41 53 41 41 41 41 41
5 42 54 42 42 57 42 42
6 43 55 43 43 58 43 43
7 44 56 44 44 59 44 44
5 45 57 45 45 45 45 45
6 46 58 46 46 61 46 46
7 47 59 47 47 62 47 47
8 48 60 48 48 63 48 48
3 49 49 49 49 49 49 49
4 50 50 50 50 65 50 50
5 51 51 51 51 66 51 51
6 52 52 52 52 67 52 52
4 53 65 53 53 53 53 53
5 54 66 54 54 69 54 54
6 55 67 55 55 70 55 55
7 56 68 56 56 71 56 56
5 57 69 57 57 57 57 57
6 58 70 58 58 73 58 58
7 59 71 59 59 74 59 59
8 60 72 60 60 75 60 60
6 61 73 61 61 61 61 61
7 62 74 62 62 77 62 62
8 63 75 63 63 78 63 63
9 64 76 64 64 79 64 64
@COLORS
0 0 0 0
1 255 255 0
2 127 127 0
3 102 32 0
4 255 255 255
5 136 136 136
6 34 34 34