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. |
This is just the central routine for a small world. |
||
<syntaxhighlight lang="futurebasic"> |
<syntaxhighlight lang="futurebasic"> |
||
Short a(4, 4), c(4, 4) // Array of cells and working copy |
Short a(4, 4), c(4, 4) // Array of cells and working copy |
||
void local fn |
void local fn seed |
||
Short x, y |
Short x, y |
||
// Fill three cells |
// Fill three cells |
||
Line 7,303: | Line 7,302: | ||
end fn |
end fn |
||
void local fn |
void local fn nextGen |
||
Short x, y, dx, dy, n |
Short x, y, dx, dy, n |
||
// Calculate next generation on temporary |
// Calculate next generation on 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 |
c(x, y) = 0 // Initialize |
||
n = -a(x, y) // Don't count center cell |
n = -a(x, y) // Don't count center cell |
||
for dy = -1 to 1 : for dx = -1 to 1 |
for dy = -1 to 1 : for dx = -1 to 1 |
||
Line 7,321: | Line 7,320: | ||
end fn |
end fn |
||
fn |
fn seed |
||
fn |
fn nextGen |
||
fn |
fn nextGen |
||
handleevents |
handleevents |
||
Line 7,347: | Line 7,346: | ||
00000 |
00000 |
||
00000 |
00000 |
||
</pre> |
</pre> |
||
Line 8,011: | Line 8,008: | ||
0 0 0 |
0 0 0 |
||
1 1 1 |
1 1 1 |
||
0 0 0 |
0 0 0 |
||
</syntaxhighlight> |
|||
'''Example''' (showing start and six following generations of a glider) |
'''Example''' (showing start and six following generations of a glider) |