M=1 is simply 2D Moore; M=2 means a cell can remember its previous generation; etc.
(We treat evolutionary sequences of 2D CA as 3D structures, just as how we treated 1D as 2D)
Then, when M=3, a cell and its neighborhood is:
Code: Select all
3D version=1 size=100 pos=36,51,49
x=3 y=4 z=3 rule=3D5..7/6
$3o$3o$3o/bo$3o$3o$3o/$3o$3o$3o!
Code: Select all
birth = [5,9]
survival = [3,4,5,8]
memory = 2
name = "B"
for i in birth: name += str(i) + ","
name += "S"
for i in survival: name += str(i) + ","
name += "M" + str(memory)
n_states = 2 ** memory
n_neighbors = 8
def tobinary(n):
res = []
while n != 0:
res.append(n % 2)
n = n // 2
while len(res) < memory:
res.append(0)
return res
def append(n, new):
binlist = [new] + tobinary(n)[:-1]
res = 0
while len(binlist) != 0:
res *= 2
res += binlist.pop()
return res
def onbitinbin(n):
binlist = tobinary(n)
cnt = 0
for i in binlist: cnt += i
return cnt
def transition_function(a):
n = 0
for i in a[:-1]:
n += onbitinbin(i)
if n in survival and a[8] % 2 == 1:
return append(a[8], 1)
if n in birth and a[8] % 2 == 0:
return append(a[8], 1)
return append(a[8], 0)The rule in the script is B5,9/S3,4,5,8/M2, you can change it.
B5,9/S3,4,5,8/M2
This rule has a small P30:
Code: Select all
x = 4, y = 3, rule = B5,9,S3,4,5,8,M2
.2C$CB.C$.2C!
@RULE B5,9,S3,4,5,8,M2
@TREE
num_states=4
num_neighbors=8
num_nodes=60
1 0 2 0 2
2 0 0 0 0
1 0 3 0 3
2 0 0 0 2
2 0 2 2 2
3 1 3 3 4
1 1 3 1 3
2 2 2 2 6
3 3 4 4 7
2 2 6 6 0
3 4 7 7 9
4 5 8 8 10
2 6 0 0 0
3 7 9 9 12
4 8 10 10 13
3 9 12 12 3
4 10 13 13 15
5 11 14 14 16
1 1 2 1 2
2 0 2 2 18
3 12 3 3 19
4 13 15 15 20
5 14 16 16 21
2 2 18 18 0
3 3 19 19 23
4 15 20 20 24
5 16 21 21 25
6 17 22 22 26
2 18 0 0 0
3 19 23 23 28
4 20 24 24 29
5 21 25 25 30
6 22 26 26 31
3 23 28 28 1
4 24 29 29 33
5 25 30 30 34
6 26 31 31 35
7 27 32 32 36
3 28 1 1 1
4 29 33 33 38
5 30 34 34 39
6 31 35 35 40
7 32 36 36 41
3 1 1 1 1
4 33 38 38 43
5 34 39 39 44
6 35 40 40 45
7 36 41 41 46
8 37 42 42 47
4 38 43 43 43
5 39 44 44 49
6 40 45 45 50
7 41 46 46 51
8 42 47 47 52
4 43 43 43 43
5 44 49 49 54
6 45 50 50 55
7 46 51 51 56
8 47 52 52 57
9 48 53 53 58