• [^] # Re: Modélisation trop longue à débugger

    Posté par . En réponse au message Avent du Code, jour 19. Évalué à 1.

    Petite amélioration, je descends à 6s en modifiant mon DFS

    L'idée est de ne pas aller jusqu'au bout si on sait déjà qu'on sera en-dessous du meilleur temps.
    ```
    public static void executeDFS(State state) {
    int leftTurn = NB_TURN_32- state.index;
    int expGeode = state.geode+(NB_TURN_32-state.index) * (state.geodeRobot) + (leftTurn+1) * (leftTurn + 0) / 2;

    if(bestMap.get(state.bp) != null && expGeode < bestMap.get(state.bp)) {
    return;
    }

    if(state.index == NB_TURN_32) {
     if(bestMap.get(state.bp) == null || state.geode > bestMap.get(state.bp)) { 
     bestMap.put(state.bp, state.geode); 
     System.out.println("Best:" + state.bp.index +";" + state.geode); 
     }
     return;
    }
    List<String> actions =state.availablesAction();
    State newState = new State(state.bp);
    for(String action : actions) { 
     state.copyInto(newState);
     newState.transform(action);
     executeDFS(newState);
    }
    

    }
    ```