Skip to content

Instantly share code, notes, and snippets.

@PabloRegen
Last active March 4, 2019 05:37
Show Gist options
  • Save PabloRegen/ae6b1a4f14983b1103d7de10df0a2bfa to your computer and use it in GitHub Desktop.
Save PabloRegen/ae6b1a4f14983b1103d7de10df0a2bfa to your computer and use it in GitHub Desktop.
function to generate a board status
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