Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -6,52 +6,52 @@ cols = 96; colRange = range(0, cols-1)
|
|||
img = Image.create(2, 1); img.setPixel 1, 0, color.white
|
||||
grids = []
|
||||
for dispIdx in [4,5]
|
||||
display(dispIdx).mode = displayMode.tile
|
||||
td = display(dispIdx)
|
||||
td.cellSize = 9 // size of cells on screen
|
||||
td.extent = [cols, rows]
|
||||
td.overlap = -1 // adds a small gap between cells
|
||||
td.tileSet = img; td.tileSetTileSize = 1
|
||||
td.clear 0
|
||||
grids.push td
|
||||
display(dispIdx).mode = displayMode.tile
|
||||
td = display(dispIdx)
|
||||
td.cellSize = 9 // size of cells on screen
|
||||
td.extent = [cols, rows]
|
||||
td.overlap = -1 // adds a small gap between cells
|
||||
td.tileSet = img; td.tileSetTileSize = 1
|
||||
td.clear 0
|
||||
grids.push td
|
||||
end for
|
||||
|
||||
// initialize to a random state
|
||||
for x in colRange
|
||||
for y in rowRange
|
||||
td.setCell x, y, rnd > 0.5
|
||||
end for
|
||||
for y in rowRange
|
||||
td.setCell x, y, rnd > 0.5
|
||||
end for
|
||||
end for
|
||||
|
||||
curIdx = 5
|
||||
// main loop
|
||||
while true
|
||||
yield
|
||||
td = grids[curIdx-4]
|
||||
newIdx = 4 + (curIdx == 4)
|
||||
newTd = grids[newIdx-4]
|
||||
for x in colRange
|
||||
for y in rowRange
|
||||
// get sum of neighboring states
|
||||
sum = 0
|
||||
for i in [x-1, x, x+1]
|
||||
if i < 0 or i >= cols then continue
|
||||
for j in [y-1, y, y+1]
|
||||
if j < 0 or j >= rows then continue
|
||||
if i==x and j==y then continue
|
||||
sum = sum + td.cell(i,j)
|
||||
end for
|
||||
end for
|
||||
// Now, update the cell based on current state
|
||||
// and neighboring sum.
|
||||
if td.cell(x,y) then
|
||||
newTd.setCell x, y, (sum == 2 or sum == 3)
|
||||
else
|
||||
newTd.setCell x, y, sum == 3
|
||||
end if
|
||||
end for
|
||||
end for
|
||||
display(newIdx).mode = displayMode.tile
|
||||
display(curIdx).mode = displayMode.off
|
||||
curIdx = newIdx
|
||||
yield
|
||||
td = grids[curIdx-4]
|
||||
newIdx = 4 + (curIdx == 4)
|
||||
newTd = grids[newIdx-4]
|
||||
for x in colRange
|
||||
for y in rowRange
|
||||
// get sum of neighboring states
|
||||
sum = 0
|
||||
for i in [x-1, x, x+1]
|
||||
if i < 0 or i >= cols then continue
|
||||
for j in [y-1, y, y+1]
|
||||
if j < 0 or j >= rows then continue
|
||||
if i==x and j==y then continue
|
||||
sum = sum + td.cell(i,j)
|
||||
end for
|
||||
end for
|
||||
// Now, update the cell based on current state
|
||||
// and neighboring sum.
|
||||
if td.cell(x,y) then
|
||||
newTd.setCell x, y, (sum == 2 or sum == 3)
|
||||
else
|
||||
newTd.setCell x, y, sum == 3
|
||||
end if
|
||||
end for
|
||||
end for
|
||||
display(newIdx).mode = displayMode.tile
|
||||
display(curIdx).mode = displayMode.off
|
||||
curIdx = newIdx
|
||||
end while
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue