Ejemplo n.º 1
0
  public static void main(String[] args) throws FileNotFoundException {
    Maze f;
    f = new Maze("data3.dat", true); // true animates the maze.

    f.clearTerminal();
    f.solve();

    f.clearTerminal();
    System.out.println(f);
  }
Ejemplo n.º 2
0
  public static void main(String[] args) {

    Maze m = new Maze("data.dat", true);
    m.solve();

    if (m.debug) {
      System.out.println(m.maze.length + "/" + m.maze[0].length);
      System.out.println(m.maze[1][1]);
      System.out.println(m.startx);
    }
  }
Ejemplo n.º 3
0
 public static void main(String args[]) {
   Maze m = new Maze();
   m.main();
 }
Ejemplo n.º 4
0
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == start2Button) {
      maze.sol = 2;
      timer1.start();
    }
    if (e.getSource() == resetButton) {
      timer1.stop();
      timer2.stop();
      timer3.stop();
      timer4.stop();
      maze.sol = 0;
      this.maze.readFromFile("maze.txt");
      maze.repaint();
    }
    if (e.getSource() == start1Button) {
      maze.sol = 1;
      timer2.start();
      // maze.leastVisitedNeighbour();
    }
    if (e.getSource() == start3Button) {
      maze.sol = 3;
      timer3.start();
    }
    if (e.getSource() == start4Button) {
      maze.sol = 4;
      maze.dijkstra();
      timer4.start();
    }
    if (maze.sol == 2) {
      if (!maze.cells[maze.currentX][maze.currentY].isEnd()) {
        maze.stepLeastVistedNeighbour();
        maze.repaint();
      } else {
        timer1.stop();
      }
    }

    if (maze.sol == 1) {
      if (!maze.cells[maze.currentX][maze.currentY].isEnd()) {
        maze.randomStep();
        maze.repaint();
      } else {
        timer2.stop();
      }
    }
    if (maze.sol == 3) {
      if (!maze.cells[maze.currentX][maze.currentY].isEnd()) {
        maze.stepRightHand();
        maze.repaint();
      } else {
        timer3.stop();
      }
    }
    if (maze.sol == 4) {
      if (!maze.cells[maze.currentX][maze.currentY].isEnd()) {
        maze.stepDjikstra();
        maze.repaint();
      } else {
        timer4.stop();
      }
    }
  }