Zannick / logic-graph

Tools for video game logic representation and analysis, particularly routing and beatability checks for speedruns and randomizers.
MIT License
3 stars 0 forks source link

Panic in `handle_solution` on state not found in db. #197

Open Zannick opened 3 months ago

Zannick commented 3 months ago

But the state it's panicking on is not a winning state:

thread '<unnamed>' panicked at /home/bswolf/logic-graph/analyzer/src/search.rs:561:73: calledResult::unwrap()on anErrvalue: Error { message: "Could not find state entry for Context { position: Glacier__Crystals__Upper_Ledge, energy: 350, flasks: 46, refills: 3, mode: Drone, save: Emergence__Camp_Exterior__Save_Point, breach_save: Glacier_Breach__Save_and_Exit__Save_Point, indra: None, last: None, portal: Glacier__Crystals__Portal_Cage, prev_portal: None, prev_area: Glacier__Vertical_Room, big_flask: 24, flask: 46, health_fragment: 21, health_node: 4, power_matrix: 4, cbits1: ContextBits1(MAP__AMAGI_BREACH__EAST_RUINS__SAVE | MAP__AMAGI_BREACH__UPPER_LAKE__SAVE | MAP__AMAGI__MAIN_AREA__SAVE | MAP__AMAGI__EAST_LAKE__SAVE | MAP__ANNUNA__MIRROR_MATCH__SAVE | MAP__ANNUNA__VERTICAL_ROOM__SAVE | MAP__ANNUNA__UPPER_SAVE__SAVE | MAP__ANNUNA__CENTER_SAVE__SAVE | MAP__EBIH_BREACH__IN_N_OUT__SAVE | MAP__EBIH_BREACH__ROCK_BLOCK__SAVE | MAP__EBIH__BASE_CAMP__SAVE | MAP__EBIH__EBIH_WEST__MID_SAVE | MAP__EBIH__EBIH_WEST__UPPER_SAVE | MAP__EBIH__EBIH_WEST__LOWER_SAVE | MAP__EBIH__HIDDEN_PORTAL__SAVE | MAP__EMERGENCE__CAMP_EXTERIOR__SAVE | MAP__GIGUNA_BREACH__PEAK__SAVE | MAP__GIGUNA_BREACH__SW_SAVE__SAVE | MAP__GIGUNA_BREACH__LABYRINTH__SAVE | MAP__GIGUNA_BREACH__EAST__SAVE | MAP__GIGUNA__GIGUNA_NORTHEAST__SAVE | MAP__GIGUNA__GIGUNA_BASE__SAVE | MAP__GIGUNA__RUINS_WEST__SAVE | MAP__GIGUNA__RUINS_TOP__SAVE | MAP__GIGUNA__LABYRINTH__SAVE | MAP__GIGUNA__SEPARATOR__SAVE | MAP__GLACIER_BREACH__SOUTH_SAVE__SAVE | MAP__GLACIER_BREACH__WEST_SAVE__SAVE | MAP__GLACIER_BREACH__GUARDED_CORRIDOR__SAVE | MAP__GLACIER_BREACH__SAVE_AND_EXIT__SAVE | MAP__GLACIER_BREACH__HAMMONDS_BREACH__SAVE | MAP__GLACIER__REVIVAL__SAVE | MAP__IRIKAR_BREACH__SAVE_ROOM__SAVE | MAP__IRIKAR_BREACH__GAUNTLET__SAVE | MAP__IRIKAR_BREACH__BASEMENT_SAVE__SAVE | MAP__IRIKAR__HUB__SAVE | MAP__IRIKAR__MIDWEST__SAVE | MAP__UHRUM_BREACH__SAVE_AND_GO__SAVE | MAP__UHRUM_BREACH__LOCKED_DOWN__SAVE | MAP__UHRUM__WEST_ENTRANCE__SAVE | MAP__UHRUM__SAVE_ROOM__SAVE | MAP__UHRUM__ANNUNA_CORRIDOR__SAVE | MAP__UHRUM__EMERGENCE_SAVE__SAVE | GLACIER__CTX__HAMMONDS_DOORS | ANNUNA__WEST_CLIMB__CTX__DOOR_OPENED | EBIH__TRUCK_GATE__CTX__DOOR_OPEN | EBIH__GRID_25_10_12__CTX__DOOR_OPEN | EBIH__WATERFALL__CTX__WEST_DOOR_OPEN | EBIH__WATERFALL__CTX__EAST_DOOR_OPEN), cbits2: ContextBits2(GIGUNA__GIGUNA_NORTHEAST__CTX__DOOR_OPENED | GIGUNA__CARNELIAN__CTX__DOOR_OPENED | GIGUNA__EAST_CAVERNS__CTX__DOOR_OPENED | GIGUNA__LABYRINTH__CTX__DOOR | GLACIER__VERTICAL_ROOM__CTX__LOWER_GATESTONES | AANSUR | AMAGI_DRAGON_EYE_PASSAGE | AMAGI_GATED_COMMUNITY_GATE | AMASHILAMA | ANNUNA_EAST_BRIDGE_GATE | ANNUNA_VERTICAL_ROOM_GATE | ANUMAN | BECOMING_AN_ARM | BEWARE_THE_PATTERNMIND | BOOMERANG | BOOMERANG_UPGRADE | BOUNTY_LIST | BREACH_ATTRACTOR | BREACH_SIGHT | BRONZE_AXE | BUILDING_OF_THE_SCHOOL | CARNELIAN_RING | COMMEMORATIVE_SPEECH | COMPANIES_LAYOFF | COMPASS | DANGEROUS_IDEAS | DEAR_ERNEST | DEFEAT_MUS_A_M20 | DESTRUCTION_POGROM | DIVINERS_GEM), cbits3: ContextBits3(DOUBLE_AXE | DR_GLORIA | DRONE_HOVER | DRONE_MELEE_CHARGE | DRONE_MELEE_DAMAGE | DRONE_MELEE_DAMAGE_2 | DRONE_MELEE_DAMAGE_3 | DRONE_MELEE_SPEED | DRONE_MELEE_SPEED_2 | EBIH_ALU | EBIH_BREACH_ROCK_BLOCK_ROCK | EBIH_EAST_WALL | EBIH_GEM_ROOM_GATE | EBIH_WALLED_OFF_WALL | EBIH_WATERFALL_BLOCK_RIGHT | EBIH_WATERFALL_WALL | EBIH_WEST_BLOCK | EMERGENCE_DROPOFF_WALL | EMERGENCE_ROCKS_FALL_ROCK_1 | EMERGENCE_ROCKS_FALL_ROCK_2 | EMERGENCE_ROCKS_FALL_ROCK_3 | EMERGENCE_ROCKS_FALL_ROCK_4 | EMERGENCE_STORAGE_ROCK | EMERGENCE_STORAGE_TUNNEL | ENSIS_BRACELET | EXIT_BREACH | EYE_RING | FAMILY_TRAGEDY | FAST_TRAVEL | FORBIDDEN_KNOWLEDGE | FREEDOM_FROM_AANSUR | GIGUNA_BOULDER | GIGUNA_BREACH_CRAB_RAVE_GATE | GIGUNA_BREACH_LOWER_MACHINERY_GATE | GIGUNA_DUAL_PATH_SWITCH | GIGUNA_DUAL_PATH_WALL | GIGUNA_GUBI | GIGUNA_NORTHEAST_GATE | GIGUNA_SEPARATOR_BRICKS | GIGUNA_VERTICAL_INTERCHANGE_ROCK | GIGUNA_WASTELAND_DOOR | GLACIER_BREACH_SPIDERY_CONNECTOR_GATE | GLACIER_SEA_BURIAL_ROCK | GOODBYE | HAMMOND_AUTH | HEALTH_UPGRADE | HEALTH_UPGRADE_2), cbits4: ContextBits4(HEALTH_UPGRADE_3 | HERETICS_GRANDDAUGHTER | HERETICS_TABLET | ICE_AXE | INFECT | INFECT_L1 | INFECT_L2 | INFECT_L3 | INFECTION_RANGE | INFECTION_RANGE_2 | INFECTION_RANGE_3 | IRIKAR_BREACH_BURIED_TREASURE_PILLAR | IRIKAR_GUDAM | IRIKAR_ROYAL_STORAGE_WALL | JOURNAL_2049_10_29 | KAZAKH_ASSAULT | LAMENT_FOR_FOOLS | LEDGE_GRAB | LETTER_FROM_TRACE | MELEE_CHARGE | MELEE_DAMAGE | MIST_UPGRADE | NANITE_MIST | NANO_LATTICE_1 | NANO_LATTICE_2 | NANO_POINTS | NANO_POINTS_2 | NOTES_2053_02_27 | PLAGUE_OF_THOUGHTS | RANGED_DAMAGE | RE_DOES_TECHNOLOGY | RECORD_LOSSES | REMOTE_DRONE | RESEARCHERS_MISSING | ROYAL_DAGGER | ROYAL_RING | SAGIGA_ON_THE_WORLDSTREAM | SHOCKWAVE | SICKLE_SWORD | SIUNA_STORAGE_WALL | SLINGSHOT_CHARGE | SLINGSHOT_HOOK | SLINGSHOT_WEAPON | SNIPER_VALLEY_ROCK_1 | SNIPER_VALLEY_ROCK_2 | STATION_POWER | STORM_BOMB | SUBMARINE_PROGRESS | SUSPENSION_BRIDGE | SWITCH_36_11 | TERMINAL_BREAKTHROUGH_1 | TERMINAL_BREAKTHROUGH_2), cbits5: ContextBits5(THE_ETERNAL_ARM | THE_IDEAL_KIENGIR | THE_STUDENT | UDUSAN | UHRUM_ANNUNA_CORRIDOR_BLOCK | UHRUM_BREACH_ANNUNA_GATE_GATE | UHRUM_BREACH_LOCKED_DOWN_GATE | UHRUM_BREACH_OVERGROWN_RUINS_WALL | UHRUM_BREACH_ROCK_AND_GATE_GATE | UHRUM_CAVERN_WALL | UHRUM_EAST_GLITCH | UHRUM_EAST_LAKE_BLOCK | UHRUM_EMERGENCE_WALL | UHRUM_GLITCHY_CORRIDOR_ROCK | UHRUM_ROCKY_GATE_ROCK | UHRUM_WATERFALLS_BLOCK | UHRUM_WEST_ENTRANCE_GATE | UHRUM_WEST_ENTRANCE_UPPER_WALL | UHRUM_WEST_GLITCH | UNDER_SIEGE | UNDERWATER_MOVEMENT | WALL_CLIMB | VISITED_AMAGI_DRAGON_EYE_FLASK | [...]

   0: rust_begin_unwind
             at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library/std/src/panicking.rs:652:5
   1: core::panicking::panic_fmt
             at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library/core/src/panicking.rs:72:14
   2: core::result::unwrap_failed
             at /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library/core/src/result.rs:1679:5
   3: analyzer::search::Search<W,T>::handle_solution
   4: analyzer::search::Search<W,T>::extend_and_handle_solutions::{{closure}}
             at /home/bswolf/logic-graph/analyzer/src/search.rs:671:21
   5: rayon_core::join::join::call::{{closure}}
             at /home/bswolf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/join/mod.rs:102:18
   6: rayon_core::join::join_context::call_b::{{closure}}
             at /home/bswolf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/join/mod.rs:129:25
   7: rayon_core::job::StackJob<L,F,R>::run_inline
             at /home/bswolf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/job.rs:102:9
   8: rayon_core::join::join_context::{{closure}}
             at /home/bswolf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/join/mod.rs:159:36
   9: rayon_core::registry::in_worker
  10: rayon_core::join::join_context
             at /home/bswolf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/join/mod.rs:132:5
  11: rayon_core::join::join
             at /home/bswolf/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-core-1.12.1/src/join/mod.rs:105:5
  12: analyzer::search::Search<W,T>::extend_and_handle_solutions
             at /home/bswolf/logic-graph/analyzer/src/search.rs:665:9
  13: analyzer::search::Search<W,T>::recreate_store
             at /home/bswolf/logic-graph/analyzer/src/search.rs:763:9
  14: analyzer::search::Search<W,T>::process_one
             at /home/bswolf/logic-graph/analyzer/src/search.rs:1232:13
  15: analyzer::search::Search<W,T>::search::{{closure}}::{{closure}}
             at /home/bswolf/logic-graph/analyzer/src/search.rs:957:56
  1. This state is missing ESCAPE and APOCALYPSE_BOMB from the default victory rule, and potentially others (haven't searched in depth). This implies it's not a solution.
  2. The error comes from get_history which is looking up states in a loop to get the full history of a state, called from handle_solution so it's going to be a state being pointed back to from a solution.
  3. The stack trace implies that we are recreating a solution found from Similar execution, so every intermediate state should be written unless the prior state had been already processed.
  4. Under what circumstances would we not write a state into the db?