Conway's Game of Life: Difference between revisions

Content added Content deleted
No edit summary
No edit summary
Line 7,287: Line 7,287:


=={{header|FutureBasic}}==
=={{header|FutureBasic}}==
This is just the central routine for a small world.
This is just the central routine for a small world...
<syntaxhighlight lang="futurebasic">
<syntaxhighlight lang="futurebasic">


Line 7,294: Line 7,294:
void local fn seed
void local fn seed
Short x, y
Short x, y
// Fill three cells
// Blinker
a(1, 2) = 1 : a(2, 2) = 1 : a(3, 2) = 1
a(1, 2) = 1 : a(2, 2) = 1 : a(3, 2) = 1
// Draw the array
// Draw the array
Line 7,304: Line 7,304:
void local fn nextGen
void local fn nextGen
Short x, y, dx, dy, n
Short x, y, dx, dy, n
// Calculate next generation on temporary array c
// Calculate next generation in temporary array c
for y = 1 to 3 : for x = 1 to 3 // Not the border cells
for y = 1 to 3 : for x = 1 to 3 // Not the border cells
c(x, y) = 0 // Initialize
c(x, y) = 0 // Initialize
Line 7,311: Line 7,311:
n += a(x + dx, y + dy) // Count the neighbours
n += a(x + dx, y + dy) // Count the neighbours
next : next
next : next
c(x, y) = ( n == 3 ) or ( n == 2 and a(x, y) ) // Rule
c(x, y) = ( n == 3 ) or ( n == 2 and a(x, y) ) // Conway's rule
next : next
next : next
// Copy temp array to actual array and draw
// Copy temp array to actual array and draw