public static Map<Vector, Map<Vector, Integer>> distances(Set<Vector> tiles) {
        // Initialize distances
        Map<Vector, Map<Vector, Integer>> distances = new HashMap<Vector, Map<Vector, Integer>>();
        for (Vector a : tiles) {
            Map<Vector, Integer> m = new HashMap<Vector, Integer>();
            for (Vector b : tiles)
                m.put(b, Integer.MAX_VALUE - 1);
            m.put(a, 0);
            distances.put(a, m);
        }
        // Iterate to compute smallest distance between each location
        for (boolean updated = true; updated;) {
            updated = false;
            for (Vector a : tiles) {
                for (Move m : Move.getNonzeros()) {
                    Vector t = a.add(m);
                    if (tiles.contains(t)) {
                        // For each tile t adjacent to a, check if distance is better than old guess
                        for (Vector b : tiles) {
                            Map<Vector, Integer> dists = distances.get(b);
                            int prev = dists.get(t);
                            int next = dists.get(a) + 1;
                            if (next < prev) {
                                dists.put(t, next);
                                updated = true;
                            }
                        }
                    }
                }
            }
        }
        return distances;
    }