Bug - Fixed Cannot ABORT if thread activated from relay browser (Attn: Roippi)

Bale

Minion
Adventuring in the relay browser. I clicked the auto button to have mafia fill in noncombat choices automatically. Unfortunately they are set badly. So I try to abort from the mafia window by repeatedly hitting the escape key. It does not work.

I eventually stop it by going to the choice adventure section of my UI and changing the option.

Code:
[326] The Black Forest
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
[COLOR="#FF0000"]KoLmafia declares world peace.
KoLmafia declares world peace.[/COLOR]
Encounter: You Found Your Thrill
KoLmafia declares world peace.
Encounter: The Blackberry Cobbler
[COLOR="#FF0000"]KoLmafia declares world peace.
[/COLOR]Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
[COLOR="#FF0000"]KoLmafia declares world peace.
KoLmafia declares world peace.[/COLOR]
Encounter: All Over the Map
KoLmafia declares world peace.
Encounter: You Found Your Thrill
[COLOR="#FF0000"][COLOR="#FF0000"]KoLmafia declares world peace.
KoLmafia declares world peace.
[/COLOR][/COLOR]Encounter: The Blackberry Cobbler
[COLOR="#FF0000"]KoLmafia declares world peace.
[/COLOR]Encounter: All Over the Map
[COLOR="#FF0000"]KoLmafia declares world peace.
KoLmafia declares world peace.
[/COLOR]Encounter: You Found Your Thrill
[COLOR="#FF0000"]KoLmafia declares world peace.
[/COLOR]Encounter: The Blackberry Cobbler
[COLOR="#FF0000"]KoLmafia declares world peace.
KoLmafia declares world peace.[/COLOR]
Encounter: All Over the Map
[COLOR="#FF0000"]KoLmafia declares world peace.
[/COLOR]Encounter: You Found Your Thrill
[COLOR="#FF0000"]KoLmafia declares world peace.
KoLmafia declares world peace.[/COLOR]
Encounter: The Blackberry Cobbler
[COLOR="#FF0000"]KoLmafia declares world peace.
[/COLOR]Encounter: All Over the Map
KoLmafia declares world peace.
[COLOR="#FF0000"]KoLmafia declares world peace.[/COLOR]
Encounter: You Found Your Thrill
[COLOR="#FF0000"]KoLmafia declares world peace.
[/COLOR]Encounter: The Blackberry Cobbler
[COLOR="#FF0000"]KoLmafia declares world peace.
KoLmafia declares world peace.[/COLOR]
Encounter: All Over the Map
[COLOR="#FF0000"]KoLmafia declares world peace.
[/COLOR]Encounter: You Found Your Thrill
[COLOR="#FF0000"]KoLmafia declares world peace.
KoLmafia declares world peace.[/COLOR]
Encounter: The Blackberry Cobbler
[COLOR="#FF0000"]KoLmafia declares world peace.
[/COLOR]Encounter: All Over the Map
[COLOR="#FF0000"]KoLmafia declares world peace.
KoLmafia declares world peace.[/COLOR]
Encounter: You Found Your Thrill
[COLOR="#FF0000"]KoLmafia declares world peace.
[/COLOR]Encounter: The Blackberry Cobbler
[COLOR="#FF0000"]KoLmafia declares world peace.
[/COLOR]Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map
Encounter: You Found Your Thrill
Encounter: The Blackberry Cobbler
Encounter: All Over the Map

I have had a similar problem with not being able to abort a combat script activated from the relay browser, but this one is easier to describe and I don't have to show my combat script for it to be reproducible. Almost certainly an unintended result of Roippi's work at separating relay threads into their own seandbox.
 
Last edited:

fronobulax

Developer
Staff member
AFAIK same problem as discussed here. Or perhaps related since I was mashing the Stop Now button, not the Esc key.
 

Veracity

Developer
Staff member
AFAIK same problem as discussed here. Or perhaps related since I was mashing the Stop Now button, not the Esc key.
Not as related as you might think. The other thread was about stopping a relay script. This one is about stopping the execution of the "auto" button, which is not a script; it is done by this code in RelayAgent.java:

Code:
		else if ( this.path.equals( "/choice.php?action=auto" ) )
		{
			ChoiceManager.processChoiceAdventure( this.request, "choice.php", ChoiceManager.lastResponseText );
			if ( KoLmafia.refusesContinue() )
			{
				// Resubmit the choice request to let the user see it again
				KoLmafia.forceContinue();
				request.constructURLString( "choice.php?forceoption=0" );
				RequestThread.postRequest( this.request );
				RelayAgent.errorRequest = null;
			}
		}
As you can see, it interacts with the continuation state - and this is a relay agent thread and thus has its own continuation state, even though there is no ASH script running in it.

The other issue is that ChoiceManager.processChoiceAdventure is looping - which it is supposed to do, but it's apparently not detecting that it's not making progress. What were the "badly set" noncombat settings?
 

Veracity

Developer
Staff member
Actually, I can deduce what you had them set to:

The Map (923/1) -> The Blackberry Bushes (924/2) -> The Blackberry Cobbler (177/5) -> leave the house (loops The Map)

I'm not sure how we can detect that; simply returning to a choice adventure we'd visited before is not necessarily incorrect; since some choice trees are all implemented with a single choice adventure number. It probably is incorrect if you are automating a choice that we don't support internally - although again, I'm not sure how we'd detect that.
 

Veracity

Developer
Staff member
I guess another issue is that ChoiceManager.processChoiceAdventure doesn't even look at the continuation state while it's within its loop, so even your ESC key had set the thread's continuation state to ABORT, it would not have stopped.
 

Bale

Minion
I'm not sure how we can detect that; simply returning to a choice adventure we'd visited before is not necessarily incorrect; since some choice trees are all implemented with a single choice adventure number. It probably is incorrect if you are automating a choice that we don't support internally - although again, I'm not sure how we'd detect that.


I'm not suggesting you should detect it. That was clearly user error and not mafia's concern. The only bug was that mafia wouldn't let me abort.
 

Veracity

Developer
Staff member
I'm not suggesting you should detect it. That was clearly user error and not mafia's concern. The only bug was that mafia wouldn't let me abort.
That's the "only" bug?

Consider what I said: "ChoiceManager.processChoiceAdventure doesn't look at the continuation state while it's within its loop". That tells me that this is not a new bug; we just blithely keep submitting choices until we reach the end. ESC key? What's that? THAT is the "bug".

The old solution might have been "quit the loop if the continuation state is ABORT" - which should have happened only if the user said "stop" - but Roippi's changes makes that not work for RelayAgent threads which are not ASH scripts.

So, what is the new solution?

- Only the thread itself can set the Thread Local version of the continuation state, so the ESC key can't go in and change the continuation state in Relay Agent threads.
- We could have another KoLmafia-wide variable set only by ESC key (and stop button) - "aborted" or something - is checked for by KoLmafia.permitsContinue in addition to the continuation state
- We could make it impossible, somehow, for auto-choice-processing to loop infinitely because of bad settings.

Perhaps you were not suggesting option 3 - but it might be the "correct" solution to this, anyway.

It might be too hard or impossible. I like option 1, but that is not possible. So I might do option 2, although I think it is a kludge.

Perhaps when Roippi has time to spare again he'll come up with (non-kludge) option 4
 

Veracity

Developer
Staff member
Revision 14856 does option #2 - the ESC key (and stop now button) declare World Peace, which sets a global userAborted variable, which is considered by KoLmafia.permitsContinue and KoLmafia.refusesContinue, in addition to checking that the continuation state is not or is ABORT.

I'm not sure I like this, but it'll do for now. It does fix this issue; I set up the choices in a multi to look in the Black Forest, encountered the choice in the Relay Browser, said "auto" and it started looping - and a single press of the ESC key made it stop.

Having set userAborted, the only function which resets it is KoLmafia.forceContinue. We'll find out soon enough if that suffices...
 

Ensiferum

Member
Sorry for bumping this, but I am experiencing some troubles that seem to be coming from the changed ChoiceManager.

I use this crude alias to clear the Hidden City shrines:
Code:
shrines => checkpoint; ash if(item_amount($item[muculent machete]) > 0) cli_execute ("outfit Lianas"); if(item_amount($item[antique machete]) > 0) cli_execute ("outfit Lianas2"); cli_execute ("adventure 1 shrine (northwest)"); cli_execute ("adventure 1 shrine (northeast)"); cli_execute ("adventure 1 shrine (southeast)"); cli_execute ("adventure 1 shrine (southwest)"); cli_execute ("adventure 1 massive ziggurat"); cli_execute ("outfit checkpoint");
This usually worked flawlessly as long as there were no wandering monsters to consume the adventure. It still works in 14854, as I just tested it there. If there was a sphere (or a triangle later) mafia would pick it up or skip the choice if nothing was available.

With the change in r14856 this is no longer the case - it doesn't pick the choices set for the shrines and just gets stuck at the first choice adventure. CLI print is this and I have to go to the relay browser to Skip the adventure:
Code:
Internal checkpoint created.

Visit to HiddenCity: An Overgrown Shrine (Northwest) in progress...

[314] An Overgrown Shrine (Northwest)
Encounter: Earthbound and Down
Earthbound and Down

[314] An Overgrown Shrine (Northeast)
Encounter: Earthbound and Down
Earthbound and Down

[314] An Overgrown Shrine (Southeast)
Encounter: Earthbound and Down
Earthbound and Down

[314] An Overgrown Shrine (Southwest)
Encounter: Earthbound and Down
Earthbound and Down

[314] A Massive Ziggurat
Encounter: Earthbound and Down
Earthbound and Down

Returned: true

The old way allowed it to pick the spheres from the shrines or skip the choice, if the sphere was already taken.
Is this a bug?
 

Attachments

  • DEBUG_20141014.txt
    44.5 KB · Views: 26

fronobulax

Developer
Staff member
clear the Hidden City shrines:

I had the same problems yesterday with Hidden City and a couple other choice adventures. Since I was running scripts I did not write myself I had not decided whether the script was wrong or KoLmafia had changed and was filing this under Anecdotes. But sometimes anecdotes do lend credibility to other reports :)
 

Veracity

Developer
Staff member
Is this a bug?
Having looked at this in the debugger, I'm going to initially say "no".

The four shrines and the ziggurat are all adventure locations. The first three times you go there, you get lianas. If you don't have a machete, it takes a turn to clear them. Otherwise, you get rid of (one) liana per visit without taking a turn.

We want to be able to adventure in that location until all the lianas are clear. Therefore, we made the choice adventure an autostop. That means that if you adventure there and we see the choice adventure, we set the continuation state to PENDING, which will break out of the "adventure" command.

What has changed is that now at the top of the choice adventure processing loop, we don't follow the choice unless the continuation state is CONTINUE.

If there was a sphere (or a triangle later) mafia would pick it up or skip the choice if nothing was available.
How odd. What are your choice settings set to?

I'm honestly not sure that it is correct behavior for the "adventure" command to process a choice adventure which is an autostop - although you seem to depend on that behavior - but if it is correct, and you were not depending on a bug, I could fix this in several ways.

- check for permitsContinue at the end of the loop, which will allow a single choice step to be executed. However, if there is a choice chain which is is an autoStop, we would not go all the way through.
- check only for user abort, not continuation state.

I had the same problems yesterday with Hidden City and a couple other choice adventures. Since I was running scripts I did not write myself I had not decided whether the script was wrong or KoLmafia had changed and was filing this under Anecdotes. But sometimes anecdotes do lend credibility to other reports :)
The part I tagged in bold is what makes it an anecdote. You said, basically, "I had problems yesterday doing something unspecified. Is this a bug"?" That becomes very clear when you look at what I said previously and realize that we really can't say anything about your "a couple of other choice adventures", since we have no idea what they were.
 

Ensiferum

Member
How odd. What are your choice settings set to?

The settings are "unlock hidden X or get stone triangle". If none of the two is available, it defaults to skipping the choice and proceeds to the next adventure command. For the Ziggurat setting is Fight Protector specter, but when that isnt available, mafia defaults to Skip this adventure as well.

Since the 14856 change the choices are still accurately set, but mafia aborts at a choice.php encounter regardless of the choices available. Even when the spheres are still there I have to open the relay and pick them manually, otherwise i'll be stuck on the choice page forever.


and a couple other choice adventures

Edit: Oh, this also makes the Daily Dungeon automation (from daily deeds button) stop at the final adventure. I have to open the browser to pick up the fat loot token.
Edit2: And just remembered that automating Haunted Bedroom also stops after killing last adventure nighstand and requires you to take the choice from the attached non-combat in the browser.

Possibly other things too...
 
Last edited:

Veracity

Developer
Staff member
I thought about this in the shower and realized that since the purpose of an autostop is to break out of adventuring and allow you to do something else, we have to do the automation of choices, since, in general, you cannot walk away from such.

OK, revision 14866 doesn't require KoLmafia.permitsContinue() (i.e., continuation state = CONTINUE) in order to continue the choice automation loop, it now requires !KoLmafia.refusesContinue() (i.e., continuation state != ABORT && not user aborted).
 

Ensiferum

Member
Thanks! Seems to work okay.

Just a note about my previous post - I guess the bedroom after-fight noncombats weren't processed before anyway, so the change hadn't affected them.
 

fronobulax

Developer
Staff member
The part I tagged in bold is what makes it an anecdote. You said, basically, "I had problems yesterday doing something unspecified. Is this a bug"?" That becomes very clear when you look at what I said previously and realize that we really can't say anything about your "a couple of other choice adventures", since we have no idea what they were.

I resort to anecdotes when my information is incomplete but may have some value anyway. It is probably a side effect of supporting customers who have to make decisions on a timeline, rather than wait for information to be gathered. Now that I can articulate that I can reduce my assessment of the value of incomplete information here. I can be trained.

I specifically observed the behavior when trying to obtain the stone triangles from the shrines. I believe, but with less certainty, I saw it in the Palindrome, specifically when trying to start the fight with Dr. Awkward. Since we seem to have a hypothesis and a solution this is irrelevant unless there is a specific instance where the fix does not seem to work.

In general, thank you for your patience and detailed explanations. I am learning even if I am unintentionally aggravating :)
 
Top