code: public Collection<Point> validLocationsFrom(Point loc) {
          Collection<Point> validMoves = new HashSet<Point>();
          // Check for all valid movements
          for (int row = -1; row <= 1; row++) {
              for (int column = -1; column <= 1; column++) {
                  try {
                      if (isFree(new Point(loc.x + column, loc.y + row))) {
                          validMoves.add(new Point(loc.x + column, loc.y + row));
                      }
                  } catch (ArrayIndexOutOfBoundsException ex) {
                      // Invalid move!
                  }
              }
          }
          validMoves.remove(loc);
  
          return validMoves;
      }
docs: Return all neighbor empty points from a specific location point.
  @param loc source point
  @return collection of empty neighbor points.