Пример #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();
      }
    }
  }
Пример #2
0
 public boolean canMove() {
   int newRow = nextRow(row, direction);
   int newColumn = nextColumn(column, direction);
   return maze.isValid(newRow, newColumn);
 }