js/arrangeTiles.Grid.js
// Randomly numbers the tiles in the grid
Randomly numbers the tiles in the grid
Randomly numbers the tiles in the grid
function randomizeTiles() {
            var grid = [];
            for (var i = 0, j = Math.pow(gridSize, 2); i < j; i++) {
                grid.push(i);
            }
            grid.sort(function () { return 0.5 - Math.random() });
            for (var row = 0, rows = gridSize; row < rows; row++) {
                for (var col = 0, cols = gridSize; col < cols; col++) {
                    setTileState(row, col, grid.pop());
                }
            }
        }
function randomizeTiles ( ) { var grid = [ ] ; for ( var i = 0 , j = Math . pow ( gridSize , 2 ) ; i < j ; i ++ ) { grid . push ( i ) ; } grid . sort ( function ( ) { return 0.5 - Math . random ( ) } ) ; for ( var row = 0 , rows = gridSize ; row < rows ; row ++ ) { for ( var col = 0 , cols = gridSize ; col < cols ; col ++ ) { setTileState ( row , col , grid . pop ( ) ) ; } } }
Randomly numbers the tiles in the grid
Randomly numbers the tiles in the grid
// Randomize array // Step through the tiles array and assign a number to each tile