Exemplo n.º 1
0
 @Override
 public boolean isPossibleMove(RobotMove action) {
   int dir = action.getDir();
   switch (dir) {
     case 0:
       return location.getNorth() != null;
     case 1:
       return location.getEast() != null;
     case 2:
       return location.getSouth() != null;
     case 3:
       return location.getWest() != null;
     default:
       return false;
   }
 }
Exemplo n.º 2
0
  @Override
  public boolean performAction(RobotMove action) {
    if (isPossibleMove(action)) {
      int dir = action.getDir();
      switch (dir) {
        case 0:
          location = location.getNorth();
          break;
        case 1:
          location = location.getEast();
          break;
        case 2:
          location = location.getSouth();
          break;
        case 3:
          location = location.getWest();
          break;
      }
      return true;

    } else {
      return false;
    }
  }
Exemplo n.º 3
0
 public String toString() {
   return location.toString();
 }
Exemplo n.º 4
0
 @Override
 public int h() {
   return location.manhattan(goal);
 }