diff --git a/Cellular-Automata/ConwaysGameOfLife.js b/Cellular-Automata/ConwaysGameOfLife.js index 7e45af7104..956817f8a0 100644 --- a/Cellular-Automata/ConwaysGameOfLife.js +++ b/Cellular-Automata/ConwaysGameOfLife.js @@ -15,18 +15,6 @@ The Game of Life is a cellular automaton devised by the British mathematician Jo * [ [ 0, 0, 0 ], [ 1, 1, 1 ], [ 0, 0, 0 ] ] */ -// Define glider example -const glider = [ - [0, 1, 0, 0, 0, 0, 0, 0], - [0, 0, 1, 0, 0, 0, 0, 0], - [1, 1, 1, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0], - [0, 0, 0, 0, 0, 0, 0, 0] -] - /* * Generates the next generation for a given state of Conway's Game of Life. */ @@ -87,4 +75,16 @@ async function animate (cells, steps) { } } +// Define glider example +const glider = [ + [0, 1, 0, 0, 0, 0, 0, 0], + [0, 0, 1, 0, 0, 0, 0, 0], + [1, 1, 1, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0] +] + animate(glider, 16)