Last active
March 4, 2019 05:37
-
-
Save PabloRegen/ae6b1a4f14983b1103d7de10df0a2bfa to your computer and use it in GitHub Desktop.
function to generate a board status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const newBoardStatus = (cellStatus = () => Math.random() < 0.3) => { | |
const grid = []; | |
for (let r = 0; r < totalBoardRows; r++) { | |
grid[r] = []; | |
for (let c = 0; c < totalBoardColumns; c++) { | |
grid[r][c] = cellStatus(); | |
} | |
} | |
return grid; | |
}; | |
/* Returns an array of arrays, each containing booleans values | |
(40) [Array(60), Array(60), ... ] | |
0: (60) [true, false, true, ... ] | |
1: (60) [false, false, false, ... ] | |
2: (60) [false, false, true, ...] | |
... | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment