Bug - Not A Bug wrong choice in Tomb of the Unknown Your Class Here

r26287

Is mafia supposed to pick the correct dynamic choice when adventuring in Tomb of the Unknown Your Class Here? for reference this is the 2015 commit that implemented that choice

nemesis quest scripts and autoscend seem to assume so, they just use the adventure function in The Unquiet Garves:, autoscend also visits "place.php?whichplace=cemetery&action=cem_advtomb" and does run_choice(-1) after the tomb is found if the choice failed the first time,
but what actually gets picked is not always the correct answer. last time on repeated attempts from autoscend mafia took choice 2,2,2,2,3,2 despite the cli showing it had identified the choice it was taking as "wrong answer", only the last 2 was the right answer.
 

Veracity

Developer
Staff member
Adventuring in the Relay Browser, the correct answer has always been selected for me.

I only actually finish the Nemesis quest as an AT, but I go for the Epic Weapon as a Turtle Tamer or Sauceror as well, to increse buff durations.

Code:
Seal Clubber:

./Veracity_20220103.txt:19388:Took choice 1049/3: right answer

Accordion Thief:

./Veracity_20220119.txt:16995:Took choice 1049/2: right answer
./Veracity_20220201.txt:18748:Took choice 1049/1: right answer
./Veracity_20220203.txt:21225:Took choice 1049/1: right answer
./Veracity_20220206.txt:20274:Took choice 1049/3: right answer
./Veracity_20220208.txt:18417:Took choice 1049/2: right answer
./Veracity_20220213.txt:19064:Took choice 1049/3: right answer

Turtle Tamer:

./Veracity_20220106.txt:14268:Took choice 1049/2: right answer
./Veracity_20220124.txt:19063:Took choice 1049/3: right answer

Sauceror:

./Veracity_20220113.txt:15449:Took choice 1049/2: right answer
./Veracity_20220128.txt:18280:Took choice 1049/3: right answer
What classes are failing for you?

(I'm going to guess Disco Bandit. That looks for "Me. Duh.", but KoL just loves to put two spaces after a period.)
 
I monitored the results with Sauceror, based on the "wrong answer" shown in the cli I assume the relay browser would have shown the hint correctly
 

Veracity

Developer
Staff member
autoscend also visits "place.php?whichplace=cemetery&action=cem_advtomb" and does run_choice(-1) after the tomb is found if the choice failed the first time
What do you mean by "if the choice failed the first time"?

Oh. I see. I always find that choice in The Unquiet Garves, but if you fail, apparently the Unknown Tomb becomes a place you can visit.
 
What do you mean by "if the choice failed the first time"?
https://github.com/Loathing-Associa...RELEASE/scripts/autoscend/quests/optional.ash
tomb_already_found() can only happen after you found the choice in the unquiet garves but somehow failed to complete the whole adventure, possible reasons could be having the starting weapon equipped instead of in the inventory, just not having the starting weapon anymore, or I guess losing the fight, or in my case having picked the wrong answer

I had added an edit to my earlier comment https://kolmafia.us/threads/wrong-choice-in-tomb-of-the-unknown-your-class-here.27394/post-167407
 

Veracity

Developer
Staff member
If I am not mistaken, autoscend has a choiceAdventureScript. run_choice(-1) tells KoLmafia to automate the choice for you. That includes calling a configured choiceAdventureScript with the choice number and the responseText. If the script doesn't like that choice number, it can just exit and KoLmafia will use its built-in choice automation to pick a decision.

This particular choice redirects to a fight - or to a chain of the same choice number with only a single available option.

In the Relay Browser, pressing the "auto" button SHOULD automate that whole chain. I'll try it tomorrow after I free the King as a Robot AT and can do guild stuff.

What does autoscend's choiceAdventureScript do for choice 1049?
 
I concluded that, like the nemesis scripts found on this forum, autoscend has no choiceAdventureScript handling for 1049 and asks KoLmafia to automate it
 

Veracity

Developer
Staff member
Looking at ChoiceManager, automating a choice will automate through a chain of choice adventures, but will stop automation at a fight.
I alway press the "auto" button in the Relay Browser - rather than pressing the specific choice option that we annotated with an arrow. That would explain why I always see the fight. That has, literally, never failed for me.

Tomorrow, I will try closeting my stolen accordion, using "auto" on the door, "auto" on the fight - and hopefully it will automate the choice chain and leave me without a Rock and Roll Legend. I can then try the same thing at the Unknown Tomb, although surely there will be no fight there?
 
I can then try the same thing at the Unknown Tomb, although surely there will be no fight there?
There will be no answer needed and no fight
autoscend execution has to result in picking the wrong answer adventuring in The Unquiet Garves before it starts going directly to Unknown Tomb so the direct access to the tomb should not be responsible for the wrong answers
 

Veracity

Developer
Staff member
I REALLY shouldn't have to do this, but...

Poking around in autoscend. In quests/optional.ash in LX_acquireEpicWeapon:

Code:
    return autoAdv($location[The Unquiet Garves]);

This is literally the only call to adventure in the Unquiet Garves until you get Epic Weapon.

So, what the f*** does autoAdv want to do at that location? You seemed to say it called run_choice(-1) if it encounters a choice adventure?

That is in auto_adventure.ash:

Code:
    return autoAdv(1, loc, "");
So it runs a single adventure.

Code:
    boolean advReturn = adv1(loc, -1, option);
which, within KoLmafia itself:

Code:
      KoLmafia.makeRequest(adventure, 1);

So, LX_acquireEpicWeapon seems to assume it will get the choice option in a single adventure? Maybe you need to call it multiple times - or LX_NemesisQuest, which calls this - until it completes?

This is obviously not "finished". I assume you have private autoscend code to do that and are running into problems.

Assume the single adventure that adv1 finds is, in fact, the choice adventure.

adv1 -> KoLmafia.makeRequest -> KoLAdventure.run() -> GenericRequest.run()
The request redirects to choice.php&forceoption=0

Code:
    if (this.redirectLocation.startsWith("choice.php")) {
...
      this.redirectHandled = true;
      ChoiceManager.processRedirectedChoiceAdventure(this.redirectLocation);
      return true;
    }

So here, finally, we get into ChoiceManager auto-processing the choice.
That goes to

Code:
ChoiceManager.processChoiceAdventure(ChoiceManager.CHOICE_HANDLER, redirectLocation, null);
(i.e., handle it in the special CHOICE_HANDLER request with a URL and no responseText)

That method runs the redirected URL and gets the responseText.

In particular, the response that shows our first look at the Tomb of the Unknown Your Class Here? choice.

And it automates from there on.

Now, in order to reproduce this without automating the adventure, I can just adventure in Relay Browser until I see that adventure.
Which is to say, what I am seeing is the exact same text that ChoiceManager got by submitting the choice.php?forceoption=0 URL.

*** When I break the prism and start the Nemesis Quest, I will turn on debug logging in the Unquiet Garves.
*** I will save the HTML. I should be able to write a unit test that loads that HTML and digs into how ChoiceManager deals with it.

What happens if I hit the "auto" button when I look at that page?

The browser submits "choice.php?action=auto".
RelayAgent gets that and calls:

ChoiceManager.processChoiceAdventure(this.request, "choice.php", ChoiceManager.lastResponseText)

Which is to say, the exact same method submitted by auto-adventuring, but with the responseText already obtained.

Which tells me that KoLmafia's automation of the choice will go through identical code, whether the choice is submitted by auto-adventuring or by me hitting the "auto" button in the Relay Browser.

Which also tells me that the HTML I save for seeing that choice adventure is EXACTLY what I will need for writing a unit test to see if KoLmafia comes up with the "correct" option to submit for this choice.

-----

The main question is: my analysis of what autoscend is doing is through looking at the currently released code for that script.

You told me that it submitted run_choice(-1) when it sees the choice adventure.
The code that I studied does no such thing.

Can you please show me your (modified) autoscend code that adventures until it sees the choice and then automates it with run_choice(-1)?

Thank you.
 
I am not running modified autoscend code at Tomb of the Unknown Your Class Here,
So, LX_acquireEpicWeapon seems to assume it will get the choice option in a single adventure? Maybe you need to call it multiple times - or LX_NemesisQuest, which calls this - until it completes?
yes, the way autoscend works is by repeatedly calling tasks like this one in a general loop, so LX_acquireEpicWeapon would keep calling the adventure function until the tomb is found. ONCE the tomb is found, if this task isn't already satisfied, it calls autoAdvBypass("place.php?whichplace=cemetery&action=cem_advtomb"); which unless I misread it is what ultimately calls run_choice(-1); then handles the following fights and choices, for finding the tomb it is not different from these other nemesis quest scripts I mentioned and just uses the adventure function, which is why I am asking if that is supposed to automate the correct choice

Which tells me that KoLmafia's automation of the choice will go through identical code, whether the choice is submitted by auto-adventuring or by me hitting the "auto" button in the Relay Browser.

this makes sense to me. I could not fully understand the kolmafia code for how the whole choice is automated, but processing the options text and showing the hint seem correct, so my question *was if this is used during automation. since this is the case I have no idea what could be going wrong
one idea, do these dynamic choices ever get shuffled by kol while already in the choice? then the choices could be explained by some reloading bug on the script's end
 
Last edited:

Veracity

Developer
Staff member
OK. I'm going to try automating it the same way autoscend does - one adventure at a time using adv1. I wrote a little script.

adv1.ash:

Code:
// Invoke like this:
//
// To force a chain of choices ending in a fight:
//
// set choiceAdventure502=2
// set choiceAdventure505=3
// set choiceAdventure46=3
//
// call adv1 ( Spooky Forest )

void log_special_cases()
{
    void logit( boolean val, string cause )
    {
        if ( val ) {
            print( cause + " = true" );
        }
    }
    logit( in_multi_fight(), "inMultiFight" );
    logit( choice_follows_fight(), "choiceFollowsFight" );
    logit( fight_follows_choice(), "fightFollowsChoice" );
    logit( handling_choice(), "handlingChoice" );
}

void main( location loc )
{
    print( "Time to adv1( $loc[ " + loc + " ] , -1, \"\" )" );
    log_special_cases();
    boolean retval = adv1(loc, -1, "");
    print( "adv1 returned " + retval);
    log_special_cases();
}

gCLI output:

Code:
> set choiceAdventure502=2

> set choiceAdventure505=3

> set choiceAdventure46=3

> debug trace on

> call adv1 ( Spooky Forest )

Time to adv1( $loc[ The Spooky Forest ], -1, "" )

Visit to Woods: The Spooky Forest in progress...

[819] The Spooky Forest
Encounter: Arboreal Respite
Encounter: Consciousness of a Stream
Encounter: An Interesting Choice
Encounter: spooky vampire
Round 0: Veracity wins initiative!
Round 1: Veracity executes a macro!
Round 1: Veracity attacks!
Round 2: spooky vampire takes 671 damage.
Round 2: Veracity wins the fight!
...

adv1 returned true
Requests complete.

TRACE.txt:

Code:
1647779039485: Starting script: adv1.ash
1647779039496: Requesting: https://www.kingdomofloathing.com/adventure.php?snarfblat=15
1647779039564: Retrieved: https://www.kingdomofloathing.com/adventure.php?snarfblat=15
1647779039564: Requesting: https://www.kingdomofloathing.com/choice.php?forceoption=0
1647779039643: Retrieved: https://www.kingdomofloathing.com/choice.php?forceoption=0 (10285 bytes)
1647779039651: Requesting: https://www.kingdomofloathing.com/api.php?what=status&for=KoLmafia
1647779039689: Retrieved: https://www.kingdomofloathing.com/api.php?what=status&for=KoLmafia (4281 bytes)
1647779039735: Requesting: https://www.kingdomofloathing.com/choice.php?whichchoice=502&option=2&pwd
1647779039801: Retrieved: https://www.kingdomofloathing.com/choice.php?whichchoice=502&option=2&pwd (10033 bytes)
1647779039805: Requesting: https://www.kingdomofloathing.com/choice.php?whichchoice=505&option=3&pwd
1647779039879: Retrieved: https://www.kingdomofloathing.com/choice.php?whichchoice=505&option=3&pwd (10099 bytes)
1647779039884: Requesting: https://www.kingdomofloathing.com/choice.php?whichchoice=46&option=3&pwd
1647779039982: Retrieved: https://www.kingdomofloathing.com/choice.php?whichchoice=46&option=3&pwd
1647779039982: Requesting: https://www.kingdomofloathing.com/fight.php?ireallymeanit=1647779039
1647779040182: Retrieved: https://www.kingdomofloathing.com/fight.php?ireallymeanit=1647779039 (22976 bytes)
1647779040228: Requesting: https://www.kingdomofloathing.com/fight.php?action=macro&macrotext=if+hasskill+7273%0Askill+7273%0Aendif%0Amark+mafiafinal%0Aattack%0Agoto+mafiafinal
1647779040612: Retrieved: https://www.kingdomofloathing.com/fight.php?action=macro&macrotext=if+hasskill+7273%0Askill+7273%0Aendif%0Amark+mafiafinal%0Aattack%0Agoto+mafiafinal (12354 bytes)
1647779040644: Requesting: https://www.kingdomofloathing.com/api.php?what=status&for=KoLmafia
1647779040684: Retrieved: https://www.kingdomofloathing.com/api.php?what=status&for=KoLmafia (4257 bytes)
1647779040771: Finished script: adv1.ash

adv1 follows choice chains, using properties to choose the the choice option, and will automate a subsequent fight.

The expected difference for Tomb of the Unknown Your Class Here is that there is no property-controlled option for that. It has a "specialChoiceDecision1" which will parse the choice and choose the decision. It won't even look at the property.

I'll turn on DEBUG logging before I do this.

(By the way, I noticed this comment in autoscend's autoAdv() function:

Code:
    // adv1 can erroneously return false for "choiceless" non-combats
    // see https://kolmafia.us/showthread.php?25370-adv1-returns-false-for-quot-choiceless-quot-choice-adventures
    // undo all this when (if?) that ever gets fixed

Arrogant! Makes me want to just ignore that user's Bug Reports henceforth.)
 
do these dynamic choices ever get shuffled by kol while already in the choice?
used the relay browser to test this, the choices get shuffled whenever reloading the browser page, correct mafia hint is updated in the relay browser as expected,
shuffling between the time the option text is parsed and the time that choice is requested would give random 1/3 chance of success which would explain what I have observed. the autoscend script itself should not making more than one request to the choice page but this seems like the most likely hypothesis for obtaining choices that change and can be correct or not

thanks for looking into this. I should not trouble you with autoscend support however, so unless your test shows mafia itself is making some extra request I will assume this can't be reproduced here and investigate on the script's end
 

Veracity

Developer
Staff member
Code:
> debug on

> debug trace on

> call adv1 ( The Unquiet Garves )

Time to adv1( $loc[ The Unquiet Garves ] , -1, "" )

Visit to Plains: The Unquiet Garves in progress...

[828] The Unquiet Garves
Encounter: Tomb of the Unknown Your Class Here
Encounter: Tomb of the Unknown Your Class Here
Encounter: The Unknown Accordion Thief
Round 0: Veracity wins initiative!
Round 1: Veracity executes a macro!
Round 1: Veracity attacks!
Round 2: Veracity wins the fight!
...
Encounter: Tomb of the Unknown Your Class Here
Encounter: Tomb of the Unknown Your Class Here
Encounter: Tomb of the Unknown Your Class Here
You acquire an item: Rock and Roll Legend

adv1 returned true
Requests complete.

> debug off

> debug trace off

It worked. The trace file:

Code:
1647784057869: Starting script: adv1.ash
1647784058459: Requesting: https://www.kingdomofloathing.com/adventure.php?snarfblat=21
1647784058568: Retrieved: https://www.kingdomofloathing.com/adventure.php?snarfblat=21
1647784058568: Requesting: https://www.kingdomofloathing.com/choice.php?forceoption=0
1647784058821: Retrieved: https://www.kingdomofloathing.com/choice.php?forceoption=0 (11458 bytes)
1647784058835: Requesting: https://www.kingdomofloathing.com/api.php?what=status&for=KoLmafia
1647784058910: Retrieved: https://www.kingdomofloathing.com/api.php?what=status&for=KoLmafia (3967 bytes)
1647784058982: Requesting: https://www.kingdomofloathing.com/choice.php?whichchoice=1049&option=1&pwd
1647784059258: Retrieved: https://www.kingdomofloathing.com/choice.php?whichchoice=1049&option=1&pwd (10991 bytes)
1647784059266: Requesting: https://www.kingdomofloathing.com/api.php?what=status&for=KoLmafia
1647784059339: Retrieved: https://www.kingdomofloathing.com/api.php?what=status&for=KoLmafia (3967 bytes)
1647784059399: Requesting: https://www.kingdomofloathing.com/choice.php?whichchoice=1049&option=1&pwd
1647784059631: Retrieved: https://www.kingdomofloathing.com/choice.php?whichchoice=1049&option=1&pwd
1647784059632: Requesting: https://www.kingdomofloathing.com/fight.php?ireallymeanit=1647784059
1647784059926: Retrieved: https://www.kingdomofloathing.com/fight.php?ireallymeanit=1647784059 (23348 bytes)
1647784059972: Requesting: https://www.kingdomofloathing.com/fight.php?action=macro&macrotext=if+hasskill+7273%0Askill+7273%0Aendif%0Amark+mafiafinal%0Aattack%0Agoto+mafiafinal
1647784060555: Retrieved: https://www.kingdomofloathing.com/fight.php?action=macro&macrotext=if+hasskill+7273%0Askill+7273%0Aendif%0Amark+mafiafinal%0Aattack%0Agoto+mafiafinal (13656 bytes)
1647784060594: Requesting: https://www.kingdomofloathing.com/api.php?what=status&for=KoLmafia
1647784060650: Retrieved: https://www.kingdomofloathing.com/api.php?what=status&for=KoLmafia (3967 bytes)
1647784060692: Requesting: https://www.kingdomofloathing.com/choice.php
1647784060889: Retrieved: https://www.kingdomofloathing.com/choice.php (10773 bytes)
1647784060899: Requesting: https://www.kingdomofloathing.com/api.php?what=status&for=KoLmafia
1647784060966: Retrieved: https://www.kingdomofloathing.com/api.php?what=status&for=KoLmafia (3967 bytes)
1647784061036: Requesting: https://www.kingdomofloathing.com/choice.php?whichchoice=1049&option=1&pwd
1647784061292: Retrieved: https://www.kingdomofloathing.com/choice.php?whichchoice=1049&option=1&pwd (9871 bytes)
1647784061298: Requesting: https://www.kingdomofloathing.com/choice.php?whichchoice=1049&option=1&pwd
1647784061601: Retrieved: https://www.kingdomofloathing.com/choice.php?whichchoice=1049&option=1&pwd (9220 bytes)
1647784061606: Requesting: https://www.kingdomofloathing.com/choice.php?whichchoice=1049&option=1&pwd
1647784061919: Retrieved: https://www.kingdomofloathing.com/choice.php?whichchoice=1049&option=1&pwd (10061 bytes)
1647784061953: Requesting: https://www.kingdomofloathing.com/api.php?what=status&for=KoLmafia
1647784062021: Retrieved: https://www.kingdomofloathing.com/api.php?what=status&for=KoLmafia (3958 bytes)
1647784062107: Finished script: adv1.ash

I saved the HTML from the Tomb of the Unknown Your Class Here.

Code:
> test load unknown-tomb.html

Read 11,459 bytes into a 11,459 character string

> test visit-choice

choice = 1049
choice 1: "Music."
choice 2: "Stealth."
choice 3: "An accordion."

Just as expected (since the trace shows it took option 1), the "right choice" is option 1.
 

Veracity

Developer
Staff member
used the relay browser to test this, the choices get shuffled whenever reloading the browser page, correct mafia hint is updated in the relay browser as expected,
shuffling between the time the option text is parsed and the time that choice is requested would give random 1/3 chance of success which would explain what I have observed. the autoscend script itself should not making more than one request to the choice page but this seems like the most likely hypothesis for obtaining choices that change and can be correct or not

thanks for looking into this. I should not trouble you with autoscend support however, so unless your test shows mafia itself is making some extra request I will assume this can't be reproduced here and investigate on the script's end
As I demonstrated, we deal with encountering the choice in The Unquiet Garves just fine.
If you give the wrong answer at the door (which we should not do), you can try again at the Tomb.
If you lose to the ghost or fail to get the Epic Weapon, you can try again at the tomb, but there will be no initial riddle.

I did not try the "place.php?whichplace=cemetery&action=cem_advtomb" case.
You can't use adv1() for that since that is not an "adventure" location.

Good luck! I don't think this is a KoLmafia bug.
 
found the script issue with this debug trace command, autoscend had a url visit defined directly in a newer path file so it created a request just by loading its script dependence chains and that was also shuffling the tomb answer before mafia executed a choice, thank you for your help!
 

Veracity

Developer
Staff member
My pleasure. Glad you found "debug trace on" useful. A TRACE file is a LOT less verbose than a DEBUG file and is often all you need, as in this case.
 
Top