@SuppressWarnings("unchecked")
    public List<DistanceSquarePair> getAdjacentSquares(Location loc, int dist) {
        ArrayList<DistanceSquarePair> ret = new ArrayList<DistanceSquarePair>();

        int row = loc.row;
        int col = loc.col;

        for (int i = row - dist; i <= row + dist; i++) {
            for (int j = col - dist; j <= col + dist; j++) {
                int d = distance(row, col, i, j);
                GridSquare currentSquare = get(i, j);
                if (d <= dist && d != 0) {

                    if (currentSquare.getAnimal() == null ||
                            (currentSquare.getAnimal() != null &&
                            !currentSquare.getAnimal().isHiding(this))) {

                        ret.add(new DistanceSquarePair(d, currentSquare));
                    }
                }
            }
        }
        Collections.sort(ret);
        return ret;
    }