loathers / garbage-collector

Script for farming meat (and garbage) in 2003 web RPG Kingdom of Loathing
24 stars 59 forks source link

[BUG] looping after free fight when trainset cannot be reconfigured (too soon) #1702

Closed BadHorseMonkey closed 5 months ago

BadHorseMonkey commented 10 months ago

Describe the bug When running latest (with the grimorized post combat), a free fight causes an infinite loop, possibly failing to update my trainset

To Reproduce In aftercore, I ran garbo ascend (and later garbo). Following a free fight, the code got into an endless loop.

gCLI log: Visit to The Red Zeppelin's Mooring: The Red Zeppelin in progress... Preference lastAdventure changed from Barf Mountain to The Red Zeppelin

[718] The Red Zeppelin Preference lastEncounter changed from garbage tourist to red butler Encounter: red butler Preference _lastCombatStarted changed from 20231031060500 to 20231031061107 Round 1: Your toy train moves ahead to the Meat Mine Sluice. The sluice opens and pours out some meat! Preference trainsetPosition changed from 668 to 669 You gain 801 Meat. Round 1: You lose 10 hit points Round 2: Mad Carew wins the fight! You acquire an item: lemon (4) After Battle: Something falls out of your can of mixed everything. You acquire an item: New Zealand iced tea You gain 661 Meat You gain 14 Meat. After Battle: Nearly all credible zoologists agree that the red butler 's guts are so hot, even just imagining cutting one open and crawling inside will keep you warm for hours. You acquire an effect: Imagining Guts (10) You acquire an item: glark cable After Battle: You gain 40 Fortitude After Battle: You gain 21 Wizardliness After Battle: You gain 33 Chutzpah Preference _glarkCableUses changed from 4 to 5 Preference lastCopyableMonster changed from garbage tourist to red butler This combat did not cost a turn

Preference _concoctionDatabaseRefreshes changed from 546 to 547 logPreferenceChangeFilter => _lastCombatStarted,auto_maximize_current,garboEmbezzlerCount,garboEmbezzlerDate,garboEmbezzlerSources,libram_savedMacro,maximizerMRUList,spadingData,testudinalTeachings Preference logPreferenceChangeFilter changed from auto_maximize_current,garboEmbezzlerCount,garboEmbezzlerDate,garboEmbezzlerSources,libram_savedMacro,maximizerMRUList,spadingData,testudinalTeachings to _lastCombatStarted,auto_maximize_current,garboEmbezzlerCount,garboEmbezzlerDate,garboEmbezzlerSources,libram_savedMacro,maximizerMRUList,spadingData,testudinalTeachings Preference customCombatScript changed from garbo to grimoire_macro CCS set to grimoire_macro

Executing Postcombat/Workshed: model train set CCS set to grimoire_macro Autoattack is disabled. Submitting option 1 for choice 1485

Executing Postcombat/Workshed: model train set Autoattack is disabled. Submitting option 1 for choice 1485

Expected behavior No loop.

Session Log

Executing Postcombat/Workshed: model train set CCS: [default]\n ";" Took choice 1485/1: unknown choice.php?whichchoice=1485&option=1&forceoption=0&slot[0]=15&slot[1]=20&slot[2]=19&slot[3]=2&slot[4]=3&slot[5]=8&slot[6]=1&slot[7]=7&pwd

Additional context

Let me know if I can help you narrow this down.

BadHorseMonkey commented 10 months ago

additional information: This happened when it was too soon to reconfigure my train set.

After a few manual adventures to get past that, it was able to run successfully.

This should be something you can check. We may need to expose something in KoLmafia if it's not.

dapanda1 commented 10 months ago

I have the same looping issue with a item after the free fight. My command is: garbo ascend nobarf

The error looping message is: Executing Postcombat/Refill Cinch Autoattack is disabled.

Log details: Visit to Dinseylandfill: Barf Mountain in progress...

[499] Barf Mountain Preference lastEncounter changed from Welcome to Barf Mountain to angry tourist Encounter: angry tourist Round 0: dapanda wins initiative! Preference cosmicBowlingBallReturnCombats changed from 2 to 1 Round 1: You lose 1 hit point Round 1: dapanda executes a macro! Round 1: dapanda casts %FN, LET'S PLEDGE ALLEGIANCE TO A ZONE! You acquire an effect: Citizen of a Zone (1) Round 2: Frubert shoots a large firework rocket at your foe, causing 35 damage. The red glare it gives off, and the way it bursts in the air, reminds you of something you can't quite put a finger on, but it's very inspiring. Round 2: You gain 35 Mana Points Round 2: dapanda casts SNOKEBOMB! Round 3: You gain 2 Enchantedness Banish of angry tourist by snokebomb failed, as monsters from this area cannot be banished. Preference _snokebombUsed changed from 0 to 1 Preference _juneCleaverFightsLeft changed from 1 to 0 Preference _juneCleaverCold changed from 21 to 22 Preference _pantsgivingCount changed from 0 to 1 Preference lastCopyableMonster changed from medusa to angry tourist This combat did not cost a turn Preference _lastCombatWon changed from true to false Preference familiarSweat changed from 495 to 496 Preference _citizenZone changed from to Barf Mountain Preference _citizenZoneMods changed from to Meat Drop: +50, Hot Damage: +10, Hot Spell Damage: +10, Mysticality: +10

logPreferenceChangeFilter => _lastCombatStarted,libram_savedMacro,maximizerMRUList,testudinalTeachings Preference logPreferenceChangeFilter changed from _lastCombatStarted,garboEmbezzlerCount,garboEmbezzlerDate,garboEmbezzlerSources,libram_savedMacro,maximizerMRUList,spadingData,testudinalTeachings to _lastCombatStarted,libram_savedMacro,maximizerMRUList,testudinalTeachings Preference customCombatScript changed from garbo to grimoire_macro CCS set to grimoire_macro

Executing Postcombat/Florist Plants CCS set to grimoire_macro Autoattack is disabled. Submitting option 1 for choice 720 Preference _floristPlantsUsed changed from to Stealing Magnolia Submitting option 1 for choice 720 Preference _floristPlantsUsed changed from Stealing Magnolia to Stealing Magnolia,Aloe Guv'nor Submitting option 1 for choice 720 Preference _floristPlantsUsed changed from Stealing Magnolia,Aloe Guv'nor to Stealing Magnolia,Aloe Guv'nor,Pitcher Plant

Executing Postcombat/June Cleaver CCS set to grimoire_macro choiceAdventure1468 => 4 Preference choiceAdventure1468 changed from 2 to 4 choiceAdventure1470 => 4 Preference choiceAdventure1470 changed from 2 to 4 choiceAdventure1473 => 4 Preference choiceAdventure1473 changed from 1 to 4

Preference nextAdventure changed from Barf Mountain to Noob Cave

Visit to Mountain: Noob Cave in progress... Preference lastAdventure changed from Barf Mountain to Noob Cave

[499] Noob Cave Preference lastEncounter changed from angry tourist to Bath Time Encounter: Bath Time Preference juneCleaverQueue changed from 1475,1474,1470,1469,1471,1472 to 1474,1470,1469,1471,1472,1473 Preference _juneCleaverSkips changed from 2 to 3 Preference _juneCleaverFightsLeft changed from 0 to 8

Executing Postcombat/Refill Cinch CCS set to grimoire_macro Autoattack is disabled.

horrible-little-slime commented 10 months ago

I'll need a session log, I gotta take a look at those juicy train prefs

dapanda1 commented 10 months ago

The Executing Postcombat/Refill Cinch issue has been resolved for me with the newest update:

commit 1d57e5565e4cd0821c58214386f6e0a7f80e6efd Author: pstalcup legomaniac0117@gmail.com Date: Tue Oct 31 12:43:08 2023 GMT Fix missing cinch off by 1 error (#1703)

horrible-little-slime commented 10 months ago

additional information: This happened when it was too soon to reconfigure my train set.

After a few manual adventures to get past that, it was able to run successfully.

This should be something you can check. We may need to expose something in KoLmafia if it's not.

we currently use this code:

    available: (): boolean => {
      if (!TrainSet.canConfigure()) return false;
      if (!get("trainsetConfiguration")) {
        // Visit the workshed to make sure it's actually empty, instead of us having not yet seen it this run
        visitUrl("campground.php?action=workshed");
        visitUrl("main.php");
      }

      if (!get("trainsetConfiguration")) return true;
      if (globalOptions.ascend && estimatedGarboTurns() <= 40) return false;
      const bestStations = getPrioritizedStations();
      if (bestStations.includes(TrainSet.next())) return false;
      return true;
    },
from libram, `canConfigure` looks like this:
```
/**

/**

I don't immediately see anything wrong here, but who knows. I also have not personally encountered this, which mostly just means it doesn't always happen. So there must be some misalignment or weird confluence of events.

BadHorseMonkey commented 10 months ago

Preference trainsetPosition changed from 668 to 669 line 15810 Mad_Carew_20231031.txt

Gawea1 commented 10 months ago

I got something similar with the mayo clinic:

Preference nextAdventure changed from Barf Mountain to Uncle Gator's Country Fun-Time Liquid Waste Sluice

Visit to Dinseylandfill: Uncle Gator's Country Fun-Time Liquid Waste Sluice in progress...

[10376] Uncle Gator's Country Fun-Time Liquid Waste Sluice Preference lastEncounter changed from Skeezy the Jug Rat to Cbzzter the Grisly Bear Encounter: Cbzzter the Grisly Bear Round 0: gawea wins initiative! Round 1: You lose 45 hit points Round 1: Mushy puts your foe's entire head in its mouth, and your foe doesn't like that one bit. Round 1: Cbzzter the Grisly Bear drops 63 attack power. Round 1: Cbzzter the Grisly Bear drops 63 defense. Round 1: gawea executes a macro! Round 1: gawea casts EXTRACT JELLY! Round 2: Mushy latches onto your foe's butt, and starts draining it of... well not what you might be thinking. It's more like butt energy? It turns out butt energy smells bad, and so does the glob of stench jelly that Mushy squirts into your hand when it's done. You acquire an item: stench jelly Preference _spaceJellyfishDrops changed from 1 to 2 Round 2: You lose 78 hit points Round 2: gawea casts FEEL HATRED! Round 3: You gain 1 Enchantedness Banish of Cbzzter the Grisly Bear by Feel Hatred failed, as monsters from this area cannot be banished. Preference _feelHatredUsed changed from 0 to 1 Preference sweat changed from 7 to 9 Preference lastCopyableMonster changed from Skeezy the Jug Rat to Cbzzter the Grisly Bear This combat did not cost a turn Preference familiarSweat changed from 1069 to 1072

Preference _meatperhp changed from 0.0205686630369026 to 0.020550015110305228 allowNonMoodBurning => false Preference allowNonMoodBurning changed from true to false Preference customCombatScript changed from garbo to grimoire_macro CCS set to grimoire_macro

Executing Postcombat/Workshed: portable Mayo Clinic CCS set to grimoire_macro Autoattack is disabled.

Executing Postcombat/Workshed: portable Mayo Clinic Autoattack is disabled.

Executing Postcombat/Workshed: portable Mayo Clinic Autoattack is disabled

docrostov commented 10 months ago

adding my log to the list Captain_Scotch_20231104.txt

a full mafia restart seemed to clear it up but now i'll have to pay more attention lol

BadHorseMonkey commented 10 months ago

occurred again today, after restarting garbo following wierd rollover alert at 72000 seconds until rollover. (see other bug).

Name Value Default Scope
lastTrainsetConfiguration 631
trainsetConfiguration coal_hopper,oil_refinery,tower_frozen,groin_silo,meat_mine,tower_fizzy,brawn_silo,tower_sewage
trainsetPosition 671

Mad_Carew_20231109.txt

midgleyc commented 10 months ago
export function nextConfigurable(): number {
  return clamp(
    get("lastTrainsetConfiguration") + 40 - get("trainsetPosition"),
    0,
    40
  );
}

I don't think this is right. This has it be 40 turns until the next reset, but I think it's actually 40 turns + finish the lap you're currently on? I might be wrong here.

horrible-little-slime commented 10 months ago
export function nextConfigurable(): number {
  return clamp(
    get("lastTrainsetConfiguration") + 40 - get("trainsetPosition"),
    0,
    40
  );
}

I don't think this is right. This has it be 40 turns until the next reset, but I think it's actually 40 turns + finish the lap you're currently on? I might be wrong here.

I consulted @docrostov and he said the logic seemed correct based on his understanding of the trainset. I think @libraryaddict has suggested the issue is related to this: https://kolmafia.us/threads/lasttrainsetconfiguration-incorrectly-reset-during-initialization.29261/

horrible-little-slime commented 9 months ago

Irrat has placed a 10m bounty on debug logs relating to this: https://discord.com/channels/466605739838930955/781270875080622080/1173445213495242792

ktpolanski commented 9 months ago

How to (sloppily) unstick from this: my lastTrainsetConfiguration was on 247, my trainsetPosition was at 288, the train didn't look like it finished. I didn't understand exactly by how much to offset the prefs so that things would be happy, so I moved lastTrainsetConfiguration to 287 as the train looked like it was at the first stop and I didn't know any better (it was in fact of the first stop, but of the last lap). Garbo continued running successfully, and seems to have managed to reconfigure the trainset just fine since. As such, move lastTrainsetConfiguration up, possibly more smartly than me, and you'll be fine.

How I ended up in this state: I caught a cosmic ray mall search autumnaton thing, and garbo aborted. Somehow my lastTrainsetConfiguration got moved back from 252 to 247 by the time I relaunched my wrapper (I'm pretty sure I'm relaunched by the time "You are currently a member of Alliance From Heck" shows up in the log at line 49737). I think I did a refresh all before relaunching but I don't remember, and the command history is lost to me trying to fix this by restarting mafia. Seems like some sort of freak mafia bug?

DanceCommander6_20231113.txt

horrible-little-slime commented 9 months ago

Has anyone encountered this since #1747 ?

horrible-little-slime commented 5 months ago

Closing, given the radio silence since #1747