private static int[] decideDirection(boolean[][] maze, int x, int y){ //attempts to move up if (Random.Int(4) == 0 && //1 in 4 chance checkValidMove(maze, x, y, new int[]{0, -1})){ return new int[]{0, -1}; } //attempts to move right if (Random.Int(3) == 0 && //1 in 3 chance checkValidMove(maze, x, y, new int[]{1, 0})){ return new int[]{1, 0}; } //attempts to move down if (Random.Int(2) == 0 && //1 in 2 chance checkValidMove(maze, x, y, new int[]{0, 1})){ return new int[]{0, 1}; } //attempts to move left if ( checkValidMove(maze, x, y, new int[]{-1, 0})){ return new int[]{-1, 0}; } return null; }
private static int[] decideDirection(boolean[][] maze, int x, int y){ //attempts to move up if (Random.Int(4) == 0 && //1 in 4 chance checkValidMove(maze, x, y, new int[]{0, -1})){ return new int[]{0, -1}; } //attempts to move right if (Random.Int(3) == 0 && //1 in 3 chance checkValidMove(maze, x, y, new int[]{1, 0})){ return new int[]{1, 0}; } //attempts to move down if (Random.Int(2) == 0 && //1 in 2 chance checkValidMove(maze, x, y, new int[]{0, 1})){ return new int[]{0, 1}; } //attempts to move left if ( checkValidMove(maze, x, y, new int[]{-1, 0})){ return new int[]{-1, 0}; } return null; }
maze[x][y] = FILLED; moves++; } while (Random.Int(moves) == 0 && checkValidMove(maze, x, y, mov));
maze[x][y] = FILLED; moves++; } while (Random.Int(moves) == 0 && checkValidMove(maze, x, y, mov));