private void updateStates() {
        State aux;
        for (State m : successors) {
            aux = states.get(m.puzzle.getKey());
            if (aux != null) {
                if (aux.opened) {
                    if (m.getStartDistance() < aux.getStartDistance()) {
                        openedStates.remove(aux);
                        aux.setTotalDistance(m.getStartDistance(), m.getFinalDistance());
                        aux.father = m.father;
                        m.opened = true;
                        openedStates.add(m);
                    }
                } else {
                    if (m.getStartDistance() < aux.getStartDistance()) {
                        aux.setTotalDistance(m.getStartDistance(), m.getFinalDistance());
                        aux.father = m.father;
                        aux.opened = true;
                    }   
                    openedStates.add(aux);
                }
            } else {
                m.opened = true;
                openedStates.add(m);
                states.put(m.puzzle.getKey(), m);
            }

        }

    }