我正试图写一个algoritim,在马齐里找到并展示道路。
马奇提纲从投入文件读到,储存在2D阵列。
我需要从头开始马齐格(1,1),并通过马齐格找到任何道路。
我有一套我能够用我写到的手法,但在找到出走后,我需要展示一条通过打脚踏走到那里的道路(我目前无法做,这是我需要帮助的)。 一旦找到目标,就应当把工作 st到完成,并且只包括找到目标的道路。 (此时此刻,我只想改变会议室内的价值,但我知道如何这样做)
请回顾一下,在什么地方,我的推动正在发生,并就如何推动和淡化事情,从而达到上述标准提供一些指导。
Any assistance is greatly appreciated. Thank you.
目前的产出如下: o最初是一个空洞的空间,但在被检测为目标时,它已经改变。
********************
* * *
** ** ***** ** *****
* * * * * *
* * * * * * *
* * * *
************* ** *
* O
********************
法典:
public void findPath() {
Room start = rooms[1][1];
push(start);
while(!isEmpty()) {
current = pop();
System.out.println("The value stored in current is" + current.getValue()+ "");
if (current == null)
System.out.println("current is null");
//This is finding the goal the walls will contain a *
else if(current.getValue() == && current.getRight() == null || current.getValue() == && current.getLeft() == null || current.getValue() == && current.getUp() == null || current.getValue() == && current.getRight() == null){
current.setValue( O );
for(int i = 0; i < tos; i++ ){
pop();
}
System.out.println(" I found the end here is the path:" + current.getPrevious().getValue()+ " jjj");
} else if(current.getBlocked() == false && current.getVisited() == false) {
System.out.println("pushing currents neighbors left, right....etc" + "current is at" + current.getCord());
current.setVisited(true);
if(current.getRight() != null){
current.getRight().setPrevious(current);
push(current.getRight());
System.out.println("Inside push 1" +current.getRight().getCord());
} else {
System.out.println("Inside push right is null");
}
if(current.getLeft() != null) {
current.getLeft().setPrevious(current);
push(current.getLeft());
System.out.println("Inside push 2 " + current.getLeft().getCord());
} else {
System.out.println("Inside push left is null");
}
if(current.getUp() != null) {
current.getUp().setPrevious(current);
push(current.getUp());
System.out.println("Inside push 3" + current.getUp().getCord());
} else {
System.out.println("Inside push up is null");
}
if(current.getDown() != null) {
current.getDown().setPrevious(current);
push(current.getDown());
System.out.println("inside push 4" + current.getDown().getCord());
}
} else {
System.out.println("Inside push down is null");
}
}
for(int i = 0; i < rows ; i++) {
for(int j = 0; j < columns ; j++) {
System.out.print(rooms[i][j].getValue());
}
System.out.println();
}
}