day_21/maze_05.js
// create maze by randomly carving passages for each cell
create maze by randomly carving passages for each cell
create maze by randomly carving passages for each cell
function createBinaryTreeMaze(rows, columns) {
    let s = initializeMaze(rows, columns);
    for (let i = 0; i < rows; i++) {
        for (let j = 0; j < columns; j++) {
            let randomized  = Math.floor(Math.random() + 0.5);
            if (randomized === 1) {
                carveBottom(s, i, j);
            } else {
                carveRight(s, i, j);
            }
        }
    }
    return s;
}
function createBinaryTreeMaze ( rows , columns ) { let s = initializeMaze ( rows , columns ) ; for ( let i = 0 ; i < rows ; i ++ ) { for ( let j = 0 ; j < columns ; j ++ ) { let randomized = Math . floor ( Math . random ( ) + 0.5 ) ; if ( randomized === 1 ) { carveBottom ( s , i , j ) ; } else { carveRight ( s , i , j ) ; } } } return s ; }
create maze by randomly carving passages for each cell
create maze by randomly carving passages for each cell