diff options
-rw-r--r-- | js/life.js | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/js/life.js b/js/life.js index 7a5de14..534fdf3 100644 --- a/js/life.js +++ b/js/life.js @@ -1,10 +1,3 @@ -const initialBoard = [ - [0, 1, 0], - [0, 0, 1], - [1, 1, 1], - [0, 0, 0], -]; - const getNextState = (board) => { const rows = board.length; const cols = board[0].length; @@ -46,4 +39,42 @@ const runGame = async (initialBoard, generations) => { } }; -runGame(initialBoard, 100); +const initialBoard = [ + [0, 1, 0], + [0, 0, 1], + [1, 1, 1], + [0, 0, 0], +]; + +// runGame(initialBoard, 100); + +const rpentomino = [ + [0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0], + [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 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, 0, 0, 0, 0, 0, 0, 0, 0], +]; + +// runGame(rpentomino, 100); + +// big glider +const bigGlider = [ + [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 1, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0], +]; + +// runGame(bigGlider, 100); + +const randomBoard = Array.from({ length: 10 }, () => + Array.from({ length: 10 }, () => Math.round(Math.random())) +); + +// runGame(randomBoard, 50); \ No newline at end of file |