-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConwayGameLife.wxm
59 lines (49 loc) · 1.71 KB
/
ConwayGameLife.wxm
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
/* [wxMaxima batch file version 1] [ DO NOT EDIT BY HAND! ]*/
/* [ Created with wxMaxima version 22.04.0 ] */
/* [wxMaxima: input start ] */
life(A) := block(
[p, q, B: zerofor(A), s],
[p, q]: matrix_size(A),
for i thru p do (
for j thru q do (
s: 0,
if j > 1 then s: s + A[i, j - 1],
if j < q then s: s + A[i, j + 1],
if i > 1 then (
s: s + A[i - 1, j],
if j > 1 then s: s + A[i - 1, j - 1],
if j < q then s: s + A[i - 1, j + 1]
),
if i < p then (
s: s + A[i + 1, j],
if j > 1 then s: s + A[i + 1, j - 1],
if j < q then s: s + A[i + 1, j + 1]
),
B[i, j]: charfun(s = 3 or (s = 2 and A[i, j] = 1))
)
),
B
)$
/* [wxMaxima: input end ] */
/* [wxMaxima: input start ] */
/* a glider */
L: matrix([0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])$
/* [wxMaxima: input end ] */
/* [wxMaxima: input start ] */
gen(A, n) := block(thru n do A: life(A), A)$
/* [wxMaxima: input end ] */
/* [wxMaxima: input start ] */
gen(L, 4);
/* [wxMaxima: input end ] */
/* Old versions of Maxima abort on loading files that end in a comment. */
"Created with wxMaxima 22.04.0"$