Exemple #1
0
  public void move() {
    int newRow = nextRow(row, direction);
    int newColumn = nextColumn(column, direction);
    if (maze.isValid(newRow, newColumn)) {
      maze.updateRobot(row, column, -1);

      row = newRow;
      column = newColumn;
      maze.updateRobot(row, column, +1);

      visited.add(getPosition());
      if (debug) {
        maze.print();
      }
    }
  }
Exemple #2
0
 public Robot(Maze aMaze, int startingRow, int startingColumn) {
   maze = aMaze;
   row = startingRow;
   column = startingColumn;
   visited = new ArrayList<String>();
   visited.add(getPosition());
   maze.updateRobot(startingRow, startingColumn, 1);
 }