Conway's Game of Life: Difference between revisions
no edit summary
No edit summary |
No edit summary |
||
Line 7,287:
=={{header|FutureBasic}}==
This is just the central routine for a small world...
<syntaxhighlight lang="futurebasic">
Line 7,294:
void local fn seed
Short x, y
//
a(1, 2) = 1 : a(2, 2) = 1 : a(3, 2) = 1
// Draw the array
Line 7,304:
void local fn nextGen
Short x, y, dx, dy, n
// Calculate next generation
for y = 1 to 3 : for x = 1 to 3 // Not the border cells
c(x, y) = 0 // Initialize
Line 7,311:
n += a(x + dx, y + dy) // Count the neighbours
next : next
c(x, y) = ( n == 3 ) or ( n == 2 and a(x, y) ) //
next : next
// Copy temp array to actual array and draw
|