Jump to content

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
// Fill three cellsBlinker
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 onin temporary array c
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) ) // RuleConway's rule
next : next
// Copy temp array to actual array and draw
60

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.