Bug - Fixed Choice Handling and Goal not quite working as expected.

fronobulax

Developer
Staff member
r12700

Set up to burn all remaining turns on eXtreme slope with goal of jar of frostigkraut. Verify that Choice for eXtreme Slope 4 is set to the jar.

Run.

Mafia runs until it encounters Duffel on the Double and then loops repeating that encounter. If the relay browser is opened at that point the options displayed are to get an outfit piece and scram. If I manually select scram KoLmafia will then continue adventuring.

What I expected was for KoLmafia to pick scram without intervention since the jar was not available. (If the jar is available then I would expect it to pick the jar and then stop).
 

Darzil

Developer
What would be desired here? Show in browser if not found? Leave (and waste turns as when it's not shown once, it won't show that day) ?
 

Veracity

Developer
Staff member
How odd, since I coded it to work exactly as you describe - and it worked perfectly in my tests. I used the following as an afterEncounter script:

PHP:
string encounter = get_property( "lastEncounter" );

if ( encounter == "the remains of a jilted mistress" ||
     encounter == "Skull, Skull, Skull" ||
     encounter == "Duffel on the Double" ) {
    abort();
 }
... and ran turns in the eXtreme slope. When it failed to find the jar of Frostigkraut, it took scram and my script ran and it aborted adventuring.

(You do realize, I hope, that if you don't get the jar the first time you see the encounter that day, you will never see it that day, so "running all your adventures" will do you no good?)
 

Darzil

Developer
I can only imagine that for some reason the text "Dig deeper" wasn't displayed, which would break this in this way. Maybe we should match the choice button code rather than the displayed text, which I guess might be affected by text affecting effects.
 

fronobulax

Developer
Staff member
OK. I didn't realize that if I didn't get it the first time I should do something else.

That said, what I saw the first time was
[2734] The eXtreme Slope
Encounter: Duffel on the Double
Took choice 575/2: jar of frostigkraut
choice.php?whichchoice=575&option=2&pwd
Encounter: Duffel on the Double
Took choice 575/2: jar of frostigkraut
choice.php?whichchoice=575&option=2&pwd

until I manually launched the relay browser and selected scram at which point

Encounter: Duffel on the Double
Took choice 575/2: jar of frostigkraut
choice.php?whichchoice=575&option=2&pwd
Encounter: Duffel on the Double
Took choice 575/3: skip adventure
choice.php?pwd&whichchoice=575&option=3
Took choice 575/2: jar of frostigkraut
choice.php?whichchoice=575&option=2&pwd

[2734] The eXtreme Slope
Encounter: eXtreme cross-country hippy

It certainly looked like an infinite loop to me. It is taking a choice that does not exist, perhaps because it is only looking at my goal and not my goal and the available choices?

What I was expecting to happen is that every time the adventure came up mafia would either a) pick the jar and stop or b) pick scram and start the next adventure.

The fact that option a) has no chance of happening should not prevent b) from happening as stated, should it?

If I'm the only person this happens to then so be it, but at least I have a session log to prove it :)
 

Veracity

Developer
Staff member
Let's see a debug log, not a session log. Should be easy enough for you to reproduce, eh?
 

Darzil

Developer
The only way I can currently see this happening is if you had an effect that changed the text on the choice buttons. Not sure if there is anything that does this.

Code:
		// Duffel on the Double
		case 575:
			// Option 2 - "Dig deeper" - is not always available.
			if ( decision.equals( "2" ) && !responseText.contains( "Dig deeper" ) )
			{
				return "3";
			}
			return decision;
 

fronobulax

Developer
Staff member
The only way I can currently see this happening is if you had an effect that changed the text on the choice buttons. Not sure if there is anything that does this.

Code:
		// Duffel on the Double
		case 575:
			// Option 2 - "Dig deeper" - is not always available.
			if ( decision.equals( "2" ) && !responseText.contains( "Dig deeper" ) )
			{
				return "3";
			}
			return decision;

While we wait for the requested debug log, I propose we ponder
The 6 Stages of Debugging: 1 )That can't happen. 2) That shouldn't happen. 3) Hmmm, weird. 4) Why does that happen? 5) Oh, I see. 6 )How did that ever work?
as found in Winterbay's sig ;-)
 

Veracity

Developer
Staff member
I just tested this again with a multi. It behaved exactly as I described: I had the choice set to "2" - the jar of frostigkraut - and when it found Duffel on the Double, it automatically took option 3 - scram - instead.

That was done via autoadventuring at the eXtreme slope via the GUI. No script - except for the After-Adventure script that I posted up above so that it would abort after it saw that choice, whether or not it got the jar of frostigkraut.

Are you using a script of some sort?

In any case, I'll need to see a DEBUG log of the failure, as I said, for there to be any chance of debugging this, since it works exactly as intended when I do what you said you did.
 

fronobulax

Developer
Staff member
Hmmm. It did happen on the most scripted character. I presume BBS is the most likely culprit. Stay tuned.
 

fronobulax

Developer
Staff member
I could not get to the eXtreme slope with the character to verify but looking at BBS combined with the testimony of others has convinced me that the problem is with BBS and not KoLmafia. I have marked this as Not A Bug.

That said, I sense there is something I have not quite grasped and so want to reiterate a few things in hopes of correction.

First the mechanic is that the Jar will drop the first time that choice is encountered in a day or not at all for that day. Correct?

If I want the jar but would rather adventure somewhere else if it is not available, then what I really should do is set the choice to be to show in browser and then automate until I get the choice. When I respond to the choice I will either have a jar or know that one is not coming today. Either way, since I have other things to do I go adventure somewhere else.

If I want to burn turns on the slope anyway, but will grab a jar if one is available, then I set a goal as a jar, disable the current version of BBS and then run for as many turns as I want. If the jar is available the first time the choice is hit then mafia gets it. Then mafia sets it up so that subsequent choices do something else and autoadventuring will continue.

This would be much easier to script if KoLmafia had a preference _seenXXXXToday which would count the number of times that the character has seen choice adventure XXXX since the last rollover. This would allow BBS type scripts to be smarter about automatically setting choices and detecting unreachable goals.

Thank you for your patience with me.
 

Veracity

Developer
Staff member
How is your character adventuring? I asked that when I said "Are you using a script of some sort", but your response was simply that this was "the most scripted character". Which is vague. BBB and the ilk can set choice adventures, but how, exactly, are you running the actual adventures?

If you use the GUI and tell it to go to the eXtreme slope 100 times, that is auto-adventuring under control of KoLmafia and it will do its regular choice handling, including automatically not going for the choice which is not there.

If you use adventure() or the ilk and depend on CCS etc. to handle fights, that should behave similarly.

But you have a script that wants to handle everything, perhaps you use a function like this, that Theraze posted on the BCCAscend thread.

Code:
string run_choice( string page_text )
{
	while( contains_text( page_text , "choice.php" ) )
	{
		## Get choice adventure number
		int begin_choice_adv_num = ( index_of( page_text , "whichchoice value=" ) + 18 );
		int end_choice_adv_num = index_of( page_text , "><input" , begin_choice_adv_num );
		string choice_adv_num = substring( page_text , begin_choice_adv_num , end_choice_adv_num );
		
		string choice_adv_prop = "choiceAdventure" + choice_adv_num;
		string choice_num = get_property( choice_adv_prop );
		
		if( choice_num == "" ) abort( "Unsupported Choice Adventure!" );
		
		string url = "choice.php?pwd&whichchoice=" + choice_adv_num + "&option=" + choice_num;
		page_text = visit_url( url );
	}
	return page_text;
}
Guess what - that chooses a specific option for the choice adventure - the one in the appropriate choiceAdventureXXX setting - and uses visit_url( url ) to go there. If KoLmafia had been automating that choice, it would have changed the choice and gone to a different one, but that does not happen with visit_url(); it does what the script tells it to do and submits the url without even looking at it.

I expect that this is what you are doing - you have a script which is handling choices by manually submitting them with the choice from the preference.

Which would still make this "not a bug", since KoLmafia is simply doing exactly what you told it to do.

Are your controlling your adventures with a script? If so, can we see it?
 

fronobulax

Developer
Staff member
Well, well, well. r12716. Auto-adventure in eXtreme slope, with Jar of frostigkraut set as goal and corresponding choice adventure set to the jar. First visit to the area of the day. To the best of my knowledge, no scripts involved. Have never used BBS on this character and have disabled WHAM and UR. KoLmafia went into the loop where it is set to take choice two, which doesn't exist, and fails to take choice three.

There very well may be operator misunderstanding here, but I present a debug log in case there isn't.

Thank you for your patience.
 

Attachments

  • DEBUG_20130926.txt
    1.3 MB · Views: 41

Veracity

Developer
Staff member
Interesting. OK, I now understand what is happening. KoLmafia gets that choice, sees that option two is not available, and switches to option three. Having done that, it then checks to see if one of the choices will complete a goal, notices that choice two will do so, and switches back.

So, because you had the jar of frostigkraut as a goal - even though that wasn't going to really help you - it overrode the chosen choice. I'll see about not doing that.
 

fronobulax

Developer
Staff member
So, because you had the jar of frostigkraut as a goal - even though that wasn't going to really help you

Thank you.

If I want to farm for a jar, what is the preferred way to do that? Set the jar as a goal and autoadventure? Set the jar as a goal and set the choice adventure to get the jar? Understand that my goal should really be the choice adventure and set it to show that in the relay browser when it occurs and get the jar if it is one of the choices? None of the above?
 

Veracity

Developer
Staff member
Set the choice option to get the jar, do not use a goal, include the code I gave you above in your afterAdventureScript.
 
Top