package _4;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Random;
import java.util.Stack;
/**
@author ygch
*/
public class Maze {
private int height;
private int width;
private Random r; //随机位置生成器
private boolean blocked[][];
boolean[][] visited;//寻路过程中判断某个位置是否已经被访问过
private Stack path;//寻路过程中保存的路径
private final int[][] direction={{0, -1}, {1, 0}, {0, 1}, {-1, 0}};
/**
public Maze(int height, int width) {
super();
this.height = height;
this.width = width;
//让整个迷宫的大小为奇数,这样可以构造一行路一行墙的迷宫
if(this.height%2==0) this.height+=1;
if(this.width%2==0) this.width+=1;
r = new Random();
path= new Stack<>();
//给迷宫四周加上墙
blocked = new boolean[this.height + 2][this.width + 2];
visited=new boolean[this.height+2][this.width+2];
// 最左和最右两列置1
for (int i = 0; i < this.height + 2; i++) {
blocked[i][0] = true;
blocked[i][this.width + 1] = true;
}
// 最上和最下两行置1
for (int i = 0; i < this.width + 2; i++) {
blocked[0][i] = true;
blocked[this.height + 1][i] = true;
}
}
public int getHeight()
{
return height;
}
public int getWidth()
{
return width;
}
部分如上
希望今天早上10点前能发给我