-
Notifications
You must be signed in to change notification settings - Fork 24
/
cellular automaton
68 lines (57 loc) · 1.56 KB
/
cellular automaton
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
axlCmdRegister("cell" 'cell ?cmdType "general")
let((timer o_world o_world2)
defun(cell ()
o_world = makeTable("world")
o_world2 = makeTable("world2")
for(i 0 101
o_world[i] = makeTable("row" 0)
o_world2[i] = makeTable("row2" 0)
)
;initial condition
o_world[40][40] = 1
o_world[40][41] = 1
o_world[41][40] = 1
;o_world[42][41] = 1
axlDBCreateCircle(list(800:800 8.0) 2.0 "BOARD GEOMETRY/SILKSCREEN_TOP")
axlDBCreateCircle(list(800:820 8.0) 2.0 "BOARD GEOMETRY/SILKSCREEN_TOP")
axlDBCreateCircle(list(820:800 8.0) 2.0 "BOARD GEOMETRY/SILKSCREEN_TOP")
;axlDBCreateCircle(list(840:820 8.0) 2.0 "BOARD GEOMETRY/SILKSCREEN_TOP")
timer = axlUIWTimerAdd(nil 500 nil 'timerCallback)
)
defun(timerCallback (window timer elapsedTime)
axlClearSelSet()
axlSetFindFilter(?enabled list("noall" "lines") ?onButtons list("noall" "lines"))
for(i 1 100
for(j 1 100
o_world2[i][j] = o_world[i][j]
)
)
for(i 1 100
for(j 1 100
if(life(i j)==2
then
when(o_world[i][j]==0
axlDBCreateCircle(list(20.0*i:20.0*j 8.0) 2.0 "BOARD GEOMETRY/SILKSCREEN_TOP")
);when
o_world[i][j] = 1
else
axlAddSelectBox(list(20.0*i:20.0*j (20.0*i+8):(20.0*j+8)))
o_world[i][j] = 0
);if life
);for j
);for i
axlDeleteObject(axlGetSelSet())
)
defun(life (x y)
prog((x_count)
x_count = o_world2[x-1][y-1]+o_world2[x][y-1]+o_world2[x+1][y-1]+o_world2[x-1][y]
+o_world2[x+1][y]+o_world2[x-1][y+1]+o_world2[x][y+1]+o_world2[x+1][y+1]
return(x_count)
)
)
defun(stopTimer (l_save)
axlUIWTimerRemove(timer)
)
axlTriggerSet('save 'stopTimer)
);let
;END