English 中文(简体)
您能否提供一些假装,以显示马齐格人的道路?
原标题:Can you please provide some pseudo code to display the path of a maze?
  • 时间:2012-04-24 03:48:36
  •  标签:
  • java

我正试图写一个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();
    }
}
问题回答

不是伪装,而是谈论点:

考虑你如何穿过马齐。 如果你在整个过程中离开“read子”,因为你正在走最佳的道路,你就会把你的最佳道路贴上标签。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签