我的目标是生成一个由 Cell 对象的 2D 数组组成的迷宫。下面是单元格和迷宫的代码。使用调试器我可以看到布尔值正在改变值,并且生成按预期进行,但是当它打印出来时,没有路径。所有的墙都还在原地,我似乎无法弄清楚断开的位置,如果有的话?
这是 Cell 类:
public class Cell {
//coordinates
private int x;
private int y;
//cell status
private boolean visited;
//cell walls status
private boolean northWall;
private boolean southWall;
private boolean eastWall;
private boolean westWall;
public Cell(int x, int y) {
this.x = x;
this.y = y;
visited = false;
northWall= true;
southWall= true;
eastWall = true;
westWall = true;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public boolean isVisited() {
return visited;
}
public void setVisited(boolean visited) {
this.visited = visited;
}
public boolean isNorthWall() {
return northWall;
}
public void setNorthWall(boolean northWall) {
this.northWall = northWall;
}
public boolean isSouthWall() {
return southWall;
}
public void setSouthWall(boolean southWall) {
this.southWall = southWall;
}
public boolean isEastWall() {
return eastWall;
}
public void setEastWall(boolean eastWall) {
this.eastWall = eastWall;
}
public boolean isWestWall() {
return westWall;
}
public void setWestWall(boolean westWall) {
this.westWall = westWall;
}
汪汪一只猫
慕运维8079593
相关分类