2015-03-31 BFSDFS HW

posted Mar 31, 2015, 9:34 AM by Samuel Konstantinovich   [ updated Mar 31, 2015, 10:23 AM ]
public class Maze{
    private static final String clear =  "\033[2J";
    private static final String hide =  "\033[?25l";
    private static final String show =  "\033[?25h";
    private String go(int x,int y){
return ("\033[" + x + ";" + y + "H");
    }

    /** Same constructor as before...*/
    public Maze(String filename){     }

    public String toString();
    //do not do the funky character codes, this is used for non-animated printing,
    //it is just the string representation of the maze (before or after solving).


    public String toString(boolean animate); //do the funky character codes when animate is true
    //this to string will be used in your animate, it would include the go(0,0) character, 
    //as well as the clear/hide/show characters as you need to use them.


    /**Solve the maze using a frontier in a BFS manner. 
     * When animate is true, print the board at each step of the algorithm.
     * Replace spaces with x's as you traverse the maze. 
     */
    public boolean solveBFS(boolean animate){    }

    /**Solve the maze using a frontier in a DFS manner. 
     * When animate is true, print the board at each step of the algorithm.
     * Replace spaces with x's as you traverse the maze. 
     */
    public boolean solveDFS(boolean animate){    }

    public boolean solveBFS(){
return solveBFS(false);
    }
    public boolean solveDFS(){
return solveDFS(false);
    }
    
    /**return an array [x1,y1,x2,y2,x3,y3...]
      *that contains the coordinates of the solution from start to end.
      *Precondition :  solveBFS() OR solveDFS() has already been called (otherwise an empty array is returned)
      *Postcondition:  the correct solution is in the returned array
       */
    public int[] solutionCoordinates(){ }    

}

Comments