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(); } } }
public boolean canMove() { int newRow = nextRow(row, direction); int newColumn = nextColumn(column, direction); return maze.isValid(newRow, newColumn); }