Feature - Implemented Choice encounter confusion by non-adv.php and "walkaway" choices

Aenimus

Member
Hello,
EDIT: I think post 3 is most enlightening.

I think it's a (partially) known bug that if you don't explicitly visit choice.php after your God Lobster fight, Mafia will get confused and think you are in the last choice encounter

Code:
script "test.ash";

visit_url("place.php?whichplace=town_wrong&action=townwrong_tunnel", false);
run_choice(2);
print("The last choice number was " + last_choice());

visit_url("main.php?fightgodlobster=1");
$skill[Saucegeyser].use_skill();
print("The last choice number was " + last_choice());
run_choice(1);
print("The last choice number was " + last_choice());

abort();

The above yields:
> test.ash

Preference lastAdventure changed from None to The Tunnel of L.O.V.E.
Preference nextAdventure changed from None to The Tunnel of L.O.V.E.

[2144] The Tunnel of L.O.V.E.
Preference lastEncounter changed from Granted a Boon (#1310) to The Tunnel of L.O.V.E. (#1222)
Encounter: The Tunnel of L.O.V.E. (#1222)
Submitting option 2 for choice 1222
The last choice number was 1222
Preference _godLobsterFights changed from 0 to 1
Preference lastAdventure changed from The Tunnel of L.O.V.E. to None
Preference nextAdventure changed from The Tunnel of L.O.V.E. to None

[2144] God Lobster
Preference lastEncounter changed from The Tunnel of L.O.V.E. (#1222) to the God Lobster
Encounter: the God Lobster
Preference _lastCombatStarted changed from 20200228190521 to 20200228191026
Round 0: Aenimus wins initiative!
Round 1: Aenimus casts SAUCEGEYSER!
Round 2: God Lobster takes 7914 damage.
Round 2: Aenimus wins the fight!
After Battle: You look to the sky just in time to catch a glimpse of a falling star. Lucky! Well, not really lucky, because you totally knew it was going to be there.
After Battle: You gain 13 Muscularity Points
After Battle: You gain 233 Strongness
After Battle: You gain 118 Mysteriousness
After Battle: You gain 138 Roguishness
Preference testudinalTeachings changed from 213:3|267:3|176:0|265:3|274:5|189:2|-1:1|54:2|266:0|209:3 to 213:3|267:3|176:0|265:3|274:5|189:2|-1:1|54:2|266:1|209:3
This combat did not cost a turn
The last choice number was 1222
Submitting option 1 for choice 1222

[2144] God Lobster
Preference lastEncounter changed from the God Lobster to Granted a Boon (#1310)
Encounter: Granted a Boon (#1310)
Manual control requested for choice #1310
choice 1: "I'd like a blessing."
choice 2: "I'd like some experience."
Click here to continue in the relay browser.

Now, if we add a visit choice.php, the issue is resolved:

Code:
script "test2.ash";

visit_url("place.php?whichplace=town_wrong&action=townwrong_tunnel", false);
run_choice(2);
print("The last choice number was " + last_choice());

visit_url("main.php?fightgodlobster=1");
$skill[Saucegeyser].use_skill();
print("The last choice number was " + last_choice());
visit_url("choice.php");
run_choice(1);
print("The last choice number was " + last_choice());

abort();

The above yields:

> test2.ash

Preference lastAdventure changed from The Overgrown Lot to The Tunnel of L.O.V.E.
Preference nextAdventure changed from None to The Tunnel of L.O.V.E.

[2144] The Tunnel of L.O.V.E.
Preference lastEncounter changed from On a Downtown Train (#1308) to The Tunnel of L.O.V.E. (#1222)
Encounter: The Tunnel of L.O.V.E. (#1222)
Submitting option 2 for choice 1222
The last choice number was 1222
Preference _godLobsterFights changed from 1 to 2
Preference lastAdventure changed from The Tunnel of L.O.V.E. to None
Preference nextAdventure changed from The Tunnel of L.O.V.E. to None

[2144] God Lobster
Preference lastEncounter changed from The Tunnel of L.O.V.E. (#1222) to the God Lobster
Encounter: the God Lobster
Preference _lastCombatStarted changed from 20200228185756 to 20200228190521
Round 0: Aenimus wins initiative!
Round 1: Aenimus casts SAUCEGEYSER!
Round 2: God Lobster takes 7912 damage.
Round 2: Aenimus wins the fight!
After Battle: You glance in the direction of an inspiring meteor as it arcs across the sky, just as you predicted.
After Battle: You gain 7 Beefiness
After Battle: You gain 243 Beefiness
After Battle: You gain 115 Wizardliness
After Battle: You gain 130 Chutzpah
Preference testudinalTeachings changed from 213:3|267:3|176:0|265:3|274:5|189:2|-1:1|54:2|266:5|209:3 to 213:3|267:3|176:0|265:3|274:5|189:2|-1:1|54:2|266:0|209:3
This combat did not cost a turn
The last choice number was 1222

[2144] God Lobster
Preference lastEncounter changed from the God Lobster to Granted a Boon (#1310)
Encounter: Granted a Boon (#1310)
Submitting option 1 for choice 1310
Encounter: Granted a Boon (#1310)
You acquire an effect: Taste of the God Lobster (33)
The last choice number was 0
Script aborted.

So here is the fun part. In my main farming script, which uses a while loop and continues, if I don't "escape" certain "walkaway choices"; i.e., choice encounters where you do not need to selection an option to escape, the God Lobster fight will think you are still in the previous choice. This is in addition to visiting choice.php after run_combat() and explicit handling of choice_follows_fight() in my combat consult script. As far as I can tell, it's choices that happen outside of adv.php (so place.php or campground.php; e.g., Source Terminal).

I found that I could "escape" these choice errors by visiting the LOVE Tunnel after visiting the Source Terminal, etc. Then I tried to do the same with Lyle's Train to Downtown (/place.php?whichplace=monorail&action=monorail_downtown), and I started getting the errors again. It's likely due to its being place.php.

What I don't understand is why I am able to escape these choices with LOVE Tunnel but not Downtown in my farming script, but in the isolated example shown above, I visit either LOVE Tunnel or Downtown, and the only part that causes the error is whether I visit choice.php.

This the result of my farming script, a few weeks back, when I was not "escaping" the Source Terminal:

Round 12: God Lobster takes 361207 damage.
Round 12: You gain 20 hit points
Round 12: Aenimus wins the fight!
[snip]
This combat did not cost a turn
Unsupported choice adventure #1191
choice 1: (secret choice)
Click here to continue in the relay browser.

You're on your own, partner.

The reason why I have not included my farming script or the results themselves is because there's a lot going on, and I've tried to boil it down to the necessities with the above examples. I appreciate that I therefore haven't properly replicated the issue.

Any ideas? Can I help by getting any more data?
 
Last edited:

Aenimus

Member
Katarn also had the same issue, but this time with the latte refill:

Kazyan21/01/2020
Huh.

Code:
> choice

You aren't in a choice adventure.


And then I click to the main map in the relay browser, which brings up the choice adventure.

Code:
> choice

choice 1: "I'd like part of your regalia."
choice 2: "I'd like a blessing."
choice 3: "I'd like some experience."


Here's the weirder part, though. As I've come to suspect and has happened again today, the double run_choice(3) works on the second god lobster fight, but not the first one, and the log looks like this:

Code:
After Battle: Kazyan wins the fight!
You gain 82 Meat
After Battle: You gain 152 Strengthliness
You gain a Muscle point!
After Battle: You gain 280 Wizardliness
You gain some Mysticality points!
After Battle: You gain 160 Roguishness
You gain a Moxie point!
Submitting option 3 for choice 1329

[62] God Lobster
Encounter: Granted a Boon
Manual control requested for choice #1310
choice 1: "I'd like part of your regalia."
choice 2: "I'd like a blessing."
choice 3: "I'd like some experience."
Click here to continue in the relay browser.


...Choice 1329. Why does mafia think I'm getting a Latte Lover's refill?
 

Aenimus

Member
Sorry for the triple post; I think I have found something interesting and relevant:
Code:
script "test2.ash";

visit_url("place.php?whichplace=monorail&action=monorail_downtown");
run_choice(7);
print("The last choice number was " + last_choice());

visit_url("main.php?fightgodlobster=1");
$skill[Saucegeyser].use_skill();
print("The last choice number was " + last_choice());

abort("Complete.");

The above yields:

Code:
> set choiceAdventure1310 = 2

> test2.ash

Preference lastEncounter     changed from Granted a Boon (#1310) to On a Downtown Train (#1308)
Encounter:     On a Downtown Train (#1308)
Submitting option 7 for choice 1308
Unhandled     redirect to place.php?whichplace=monorail
The last choice number was     1308
Preference _godLobsterFights changed from 2 to 3

[2144] God     Lobster
Preference lastEncounter changed from On a Downtown Train     (#1308) to the God Lobster
Encounter: the God Lobster
Preference     _lastCombatStarted changed from 20200228193515 to 20200228193547
Round     0: Aenimus wins initiative!
Round 1: Aenimus casts SAUCEGEYSER!
Round     2: God Lobster takes 7914 damage.
Round 2: Aenimus wins the fight!
After     Battle: You gain 19 Muscularity Points
After Battle: You gain 197     Muscleboundness
After Battle: You gain 130 Wizardliness
After     Battle: You gain 165 Smarm
Preference testudinalTeachings changed from     213:3|267:3|176:0|265:3|274:5|189:2|-1:1|54:2|266:4|209:3 to     213:3|267:3|176:0|265:3|274:5|189:2|-1:1|54:2|266:5|209:3
This combat     did not cost a turn
The last choice number was 1308
Complete.

If you change the Downtown choice to the LOVE Tunnel, the choice autocompletes (set choiceAdventure1310 = 2) as expected, and you get the God Lobster reward. Both have no explicit visit to choice.php.
 
Last edited:

Veracity

Developer
Staff member
I think it's a (partially) known bug that if you don't explicitly visit choice.php after your God Lobster fight, Mafia will get confused and think you are in the last choice encounter
That is not a bug in KoLmafia. Your script MUST visit choice.php in a "choice follows fight" situation. If you don't, KoLmafia has not seen the text of the choice page and it has no idea which choice it will be in, and, therefore, cannot set the

The God Lobster fight does not redirect to choice.php. Instead, it has a link on the page to choice.php. That is KoLmafia's indication that "choice follows fight", but we have no way of knowing which choice it is until you visit choice.php. If you visit choice.php, KoL shows the choice page and KoLmafia looks at the page, scrapes the choice number, and says it where last_choice() will get it.

Looking at your first log, where you did run_choice(1) right after the fight, KoLmafia submitted a choice.php call for choice 1222 - which KoL responded to by redirecting to choice.php.

Now, if we add a visit choice.php, the issue is resolved.
Yep. If you fix the bug in your script, it behaves correctly. :)

I don't "escape" certain "walkaway choices"; i.e., choice encounters where you do not need to selection an option to escape, the God Lobster fight will think you are still in the previous choice.
I don't understand what this means. You say that if you visit the source terminal (choice 1191) - which you can walk away from - or Lyle's monorail (1308) - which you CANNOT walk away from - visiting choice.php after the God Lobster fight? Puzzling. I'll look at it. As well as you subsequent verbose posts. :)
 

Aenimus

Member
Veracity, I understand your concerns but please humour my first post for a second and take a look at the third post, which is the best replication I can make in a vacuum.

Also, these errors occur in my script, which visits choice.php and also uses choice_follows_fight().

Edit: To further clarify, if I take the exact same farming script but just swap the visits to the LOVE Tunnel to the Downtown instead, the first God Lobster fight produces the error (subsequent fights are fine).
 
Last edited:

Veracity

Developer
Staff member
Some experiments.

Code:
[color=green]> debug on[/color]
In case something weird happens and it will help me. :)

Code:
[color=green]> familiar God Lobster[/color]

Putting Bodolph the Mu back into terrarium...
Taking SnickClackClaackSnackClack the God Lobster out of terrarium...
Requests complete.

I visited the monorail in the relay browser

Code:
Encounter: On a Downtown Train

[color=green]> ash last_choice()[/color]

Returned: 1308

[color=green]> choice[/color]

choice 1: Factory District Stop (2 Adventures)
choice 6: Just ride the rails (9 Adventures)
choice 7: Nevermind, Hop Off

[color=green]> ashq visit_url( "main.php?fightgodlobster=1" )[/color]

Encounter: On a Downtown Train
Since you cannot walk away from the Monorail, KoL redirected back to the choice.

Code:
[color=green]> ashq run_choice( 7 )[/color]

Submitting option 7 for choice 1308
Unhandled redirect to place.php?whichplace=monorail

[color=green]> choice[/color]

[color=red]You aren't in a choice adventure.[/color]
Fine. Lets fight the God Lobster.

Code:
[color=green]> ashq visit_url( "main.php?fightgodlobster=1" )[/color]

[1370] God Lobster
Encounter: the God Lobster
Round 0: Veracity loses initiative!
Round 1: You lose 12 hit points

[color=green]> ashq run_combat()[/color]

Round 1: Veracity executes a macro!
...
Round 8: Veracity wins the fight!
...
This combat did not cost a turn

[color=green]> ash last_choice()[/color]

Returned: 1308

[color=green]> ashq visit_url( "choice.php" )[/color]

[1370] God Lobster
Encounter: Granted a Boon

[color=green]> ash last_choice()[/color]

Returned: 1310

[color=green]> choice[/color]

choice 1: "I'd like a blessing."
choice 2: "I'd like some experience."

[color=green]> ashq run_choice(2)[/color]

Submitting option 2 for choice 1310
You gain 500 Muscleboundness
You gain a Muscle point!
You gain 625 Wizardliness
You gain a Mysticality point!
You gain 800 Sarcasm
You can now equip a Covers-Your-Head (and possibly other things).
You gain some Moxie points!
You acquire an item: Dish of Clarified Butter
That worked perfectly. Now let's try walking away from the Source terminal. And I'll remember to try choice_follows_combat() after I win the fight this time. :)

I visit the Source Terminal in the Relay Browser
Code:
[color=green]> ash last_choice()[/color]

Returned: 1191

[color=green]> choice[/color]

choice 1: (secret choice)
  text = input
There I am! Let's walk away:

Code:
[color=green]> restore hp[/color]

Casting Cannelloni Cocoon 1 times...
You gain 436 hit points
Cannelloni Cocoon was successfully cast.

[color=green]> ash last_choice()[/color]

Returned: 1191

[color=green]> choice[/color]

[color=red]You aren't in a choice adventure.[/color]
That worked as expected. Let's go back to the Source Terminal.

Code:
[color=green]> ashq visit_url( "campground.php?action=terminal" )[/color]

[color=green]> ash last_choice()[/color]

Returned: 1191

[color=green]> choice[/color]

choice 1: (secret choice)
  text = input
Let's fight the God Lobster:

Code:
[color=green]> ashq visit_url( "main.php?fightgodlobster=1" )[/color]

[1370] God Lobster
Encounter: the God Lobster
Round 0: Veracity loses initiative!
Round 1: You lose 48 hit points

[color=green]> ashq run_combat()[/color]

Round 1: Veracity executes a macro!
...
Round 8: Veracity wins the fight!
...
This combat did not cost a turn

[color=green]> ash choice_follows_fight()[/color]

Returned: true

[color=green]> ash last_choice()[/color]

Returned: 1191

[color=green]> choice[/color]

[color=red]You aren't in a choice adventure.[/color]

[color=green]> ashq visit_url( "choice.php" )[/color]

[1370] God Lobster
Encounter: Granted a Boon

[color=green]> ash last_choice()[/color]

Returned: 1310

[color=green]> choice[/color]

choice 1: "I'd like a blessing."
choice 2: "I'd like some experience."

[color=green]> ashq run_choice( 2 )[/color]

Submitting option 2 for choice 1310
You gain 500 Strengthliness
You gain a Muscle point!
You gain 625 Enchantedness
You gain some Mysticality points!
You gain 800 Sarcasm
You gain some Moxie points!
You acquire an item: Dish of Clarified Butter

[color=green]> choice[/color]

[color=red]You aren't in a choice adventure.[/color]
Really not seeing anything that I'd characterize as a KoLmafia bug.

Your script really DOES have to visit "choice.php" if choice_follows_fight() before KoLmafia has any idea which choice it is and can submit the right URL via run_choice( # ).
 

Veracity

Developer
Staff member
Veracity, I understand your concerns but please humour my first post for a second and take a look at the third post, which is the best replication I can make in a vacuum.
Yes. You visited Lyle, exited the choice, fought the God Lobster, and, after the battle but before visiting choice.php, KoLmafia has not yet updated the choice number.

Also, these errors occur in my script, which visits choice.php and also uses choice_follows_fight().
Post #3 did not show a call on choice.php. If it had, you'd have seen:

[2144] God Lobster
Encounter: Granted a Boon

and last_choice() would be what you expected.

Edit: To further clarify, if I take the exact same farming script but just swap the visits to the LOVE Tunnel to the Downtown instead, the first God Lobster fight produces the error (subsequent fights are fine).
As I said, I saw no visit to "choice.php".

Apparently, KoL will allow to skip that and submit a "choice.php?whichchoice=X&option=Y" directly.
 

Veracity

Developer
Staff member
Edit: To further clarify, if I take the exact same farming script but just swap the visits to the LOVE Tunnel to the Downtown instead, the first God Lobster fight produces the error (subsequent fights are fine).
The LOVE tunnel is:

place.php?whichplace=town_wrong&action=townwrong_tunnel

Lyle is:

place.php?whichplace=monorail&action=monorail_downtown

Both of those redirect to choice.php. visit_url() should follow the redirects.

I have one God Lobster fight left today. Let's use the LOVE tunnel.

Code:
[color=green]> ashq visit_url( "place.php?whichplace=town_wrong&action=townwrong_tunnel" )[/color]

[1370] The Tunnel of L.O.V.E.
Encounter: The Tunnel of L.O.V.E.

[color=green]> ash last_choice()[/color]

Returned: 1222

[color=green]> choice[/color]

choice 1: Enter the Tunnel
choice 2: Leave

[color=green]> ashq visit_url( "main.php?fightgodlobster=1" )[/color]

Encounter: The Tunnel of L.O.V.E.
Just like Lyle's monorail, you cannot walk away from the LOVE tunnel

Code:
[color=green]> ashq run_choice( 2 )[/color]

Submitting option 2 for choice 1222

[color=green]> ashq visit_url( "main.php?fightgodlobster=1" )[/color]

[1370] God Lobster
Encounter: the God Lobster
Round 0: Veracity loses initiative!
Round 1: You lose 44 hit points

[color=green]> ash last_choice()[/color]

Returned: 1222

[color=green]> choice[/color]

[color=red]You aren't in a choice adventure.[/color]

[color=green]> ashq run_combat()[/color]

Round 1: Veracity executes a macro!
...
Round 6: Veracity wins the fight!
...
This combat did not cost a turn

[color=green]> ash last_choice()[/color]

Returned: 1222

[color=green]> choice[/color]

You aren't in a choice adventure.

[color=green]> ashq visit_url( "choice.php" )[/color]

[1370] God Lobster
Encounter: Granted a Boon

[color=green]> ash last_choice()[/color]

Returned: 1310

[color=green]> choice[/color]

choice 1: "I'd like a blessing."
choice 2: "I'd like some experience."

[color=green]> ashq run_choice( 2 )[/color]

Submitting option 2 for choice 1310
You gain 500 Beefiness
You gain some Muscle points!
You gain 625 Wizardliness
You gain some Mysticality points!
You gain 800 Sarcasm
You gain some Moxie points!
You acquire an item: Dish of Clarified Butter
Behaved exactly the same as Lyle's monorail (which also required you to leave the choice) and the Source Terminal (which you can walk away from).
Bothe Lyle's monorail and the LOVE tunnel are place.php.
The Source Terminal is campground.php
 

Aenimus

Member
Yes. You visited Lyle, exited the choice, fought the God Lobster, and, after the battle but before visiting choice.php, KoLmafia has not yet updated the choice number.

Yes, but if I do the exact same thing (also no visit to choice.php) using the LOVE Tunnel, it completes the choice fine*. The only difference is the choice adventure I visit before:
*it tries to enter a choice after, but the initial choice does complete.

Code:
script "test.ash";

visit_url("place.php?whichplace=town_wrong&action=townwrong_tunnel", false);
run_choice(2);
print("The last choice number was " + last_choice());

visit_url("main.php?fightgodlobster=1");
$skill[Saucegeyser].use_skill();
print("The last choice number was " + last_choice());
// NOTE LACK OF VISIT CHOICE.PHP
run_choice(1);
print("The last choice number was " + last_choice());

abort("Complete.");

Yields (note that it was successful with LOVE and not Lyle):

> test.ash

Preference lastAdventure changed from The Barrel Full of Barrels to The Tunnel of L.O.V.E.

[2144] The Tunnel of L.O.V.E.
Encounter: The Tunnel of L.O.V.E. (#1222)
Submitting option 2 for choice 1222
The last choice number was 1222
Preference _godLobsterFights changed from 0 to 1
Preference lastAdventure changed from The Tunnel of L.O.V.E. to None
Preference nextAdventure changed from The Tunnel of L.O.V.E. to None

[2144] God Lobster
Preference lastEncounter changed from The Tunnel of L.O.V.E. (#1222) to the God Lobster
Encounter: the God Lobster
Preference _lastCombatStarted changed from 20200228193547 to 20200228221938
Round 0: Aenimus wins initiative!
Round 1: Aenimus casts SAUCEGEYSER!
Round 2: God Lobster takes 3764 damage.
Round 2: Aenimus wins the fight!
After Battle: You gain 263 Strengthliness
After Battle: You gain 112 Wizardliness
After Battle: You gain 114 Roguishness
Preference testudinalTeachings changed from 213:3|267:3|176:0|265:3|274:5|189:2|-1:1|54:2|266:5|209:3 to 213:3|267:3|176:0|265:3|274:5|189:2|-1:1|54:2|266:0|209:3
This combat did not cost a turn
The last choice number was 1222
Submitting option 1 for choice 1222

[2144] God Lobster
Preference lastEncounter changed from the God Lobster to Granted a Boon (#1310)
Encounter: Granted a Boon (#1310)
Encounter: Granted a Boon (#1310)
You gain 625 Muscleboundness
You gain 625 Enchantedness
You gain 675 Chutzpah
You acquire an item: Dish of Clarified Butter
Encountered choice adventure with no choices.

Furthermore, the vacuum example was not using my normal script. I know that it didn't visit choice.php.

My farming script is:

Code:
// @TODO file clean up for skill juggling
	if (witchess_fight_can()) {
		terminal_duplicate_prepare();
		witchess_fight_run();
		cli_execute("terminal educate digitize");
		cli_execute("terminal educate extract");
		escape_choice(); // This is to resuscitate Mafia's realisation of "non-trapping choice.php"
		continue;
	}
	
	// @TODO file
	if (get_property("chateauMonster") == "Black Crayon Crimbo Elf" && !get_property("_chateauMonsterFought").to_boolean()
		&& $familiar[Robortender].try_equip()) {
		alternative_outfit().change_outfit();
		visit_url("/place.php?whichplace=chateau&action=chateau_painting", false);
		run_combat();
		continue;
	}

	// Lynyrds @TODO file
	if (get_property("_lynyrdSnareUses").to_int() < 3) {
		print("Fighting free lynyrd.", "green");
		$item[lynyrd snare].use();
		continue;
	}

	// God Lobster
	if (globster_can()) {
		globster_run(5, 2);
		continue;
	}

Code:
void escape_choice() {
	if (get_property("loveTunnelAvailable").to_boolean()) {
		visit_url("place.php?whichplace=town_wrong&action=townwrong_tunnel", false);
		run_choice(2);
		visit_url("main.php");
	} else {
		print("Need to think of a way to escape choices if one doesn't have Love Tunnel...");
	}
}

Code:
boolean globster_run(string eqp, int option) {
	int fights = globster_fights();
	item desired = ("God Lobster's " + eqp).to_item();

	if (desired == $item[none]) abort("God Lobster cannot be adorned with " + eqp + ".");
	$familiar[God Lobster].use();

	item regalis = desired.globster_closest();

	// If we can't equip what we wanted, work towards it.
	if (regalis != desired) option = 1;
	regalis.equip();

	visit_url("main.php?fightgodlobster=1");
	run_combat();
	visit_url("choice.php");
	run_choice(option);
	return fights < globster_fights();
}

In two separate sessions of my script, the only difference is that when escape_choice() visits Lyle's Downtown, Mafia stalls on the God Lobster, but the LOVE version above works fine.
 

Veracity

Developer
Staff member
Why are we trying to debug what happens when you do not call "choice.php" after the fight but before run_choice(#)?
A correct script will do something like "if ( choice_follows_fight() ) visit_url( "choice.php" )".

That said, the following is all output from run_choice(1):

Code:
Submitting option 1 for choice 1222

[2144] God Lobster
Preference lastEncounter changed from the God Lobster to Granted a Boon (#1310)
Encounter: Granted a Boon (#1310)
Encounter: Granted a Boon (#1310)
You gain 625 Muscleboundness
You gain 625 Enchantedness
You gain 675 Chutzpah
You acquire an item: Dish of Clarified Butter
Encountered choice adventure with no choices.
and everything between the first line ("Submitting option 1 for choice 1222") and the last one ("Encountered choice adventure with no choices.") looks like it was automating the choice - which should not happen with run_choice(1) - although it would, with run_choice( 1, true ). That last line was an abort, which is the lines from your script following run_choice(1) did not appear in the output.

Code:
print("The last choice number was " + last_choice());

abort("Complete.");
In two separate sessions of my script, the only difference is that when escape_choice() visits Lyle's Downtown, Mafia stalls on the God Lobster, but the LOVE version above works fine.
Why do you need "escape_choice()"?

I assume the Lyle version is something like:

Code:
		visit_url("place.php?whichplace=monorail&action=monorail_downtown", false);
		run_choice(7);
		visit_url("main.php");
I'll play with the monorail tomorrow, but I would be shocked if submitting visit_url( "choice.php?whichchoice=1308&option=7" ) after the God Lobster fight didn't redirect to choice.php.
 

Aenimus

Member
Why are we trying to debug what happens when you do not call "choice.php" after the fight but before run_choice(#)?
A correct script will do something like "if ( choice_follows_fight() ) visit_url( "choice.php" )".

Yes, I realise that it does not visit choice.php. The point is that the only difference between the two examples where NEITHER visit choice.php is where I visit before the Lobster.

That said, the following is all output from run_choice(1):

No. If you compare the outputs carefully, only the LOVE Tunnel examples reaches run_choice(1).

Method: I set Mafia automatic handling of the choice to 2 > I visit the choice > I fight the Lobster.

If I visit LOVE Tunnel, it submits a value for the choice. Then it breaks because it tried to run_choice(1) AFTER it's already completed the choice. Hence "Encountered choice adventure with no choices. ".

If I visit Lyle, it Mafia's choiceAdventure 1310 stuff and doesn't submit anything for the choice. Consequently, it never reaches run_choice(1).

Why do you need "escape_choice()"?

I don't know why. This is part of the issue--I had to visit LOVE after certain stuff to stop it tripping on the God Lobster. I just made it a function so I could call it easier.

I assume the Lyle version is something like:

Yes, exactly like this. Would it help if I ran my script using Lyle as the escape_choice() stuff? Today I used the LOVE Tunnel version, and it was fine, as expected.

I appreciate your help on this. I realise a lot of things I have said might seem dubious/PEBKAC, or that I not listening to you about choice.php.

The point I am trying to make is that it should either break the exact same for both, or work the exact same for both. But I find there to be a LOVE Tunnel and Lyle dichotomy of sorts.

Thanks!
 

Veracity

Developer
Staff member
No. If you compare the outputs carefully, only the LOVE Tunnel examples reaches run_choice(1).
Perhaps that is because the lyle code you showed me had this:

Code:
script "test2.ash";

visit_url("place.php?whichplace=monorail&action=monorail_downtown");
run_choice(7);
print("The last choice number was " + last_choice());

visit_url("main.php?fightgodlobster=1");
$skill[Saucegeyser].use_skill();
print("The last choice number was " + last_choice());

abort("Complete.");
Which is to say, you didn't actually do "run_choice(1)", but the LOVE tunnel code had this:

Code:
script "test.ash";

visit_url("place.php?whichplace=town_wrong&action=townwrong_tunnel", false);
run_choice(2);
print("The last choice number was " + last_choice());

visit_url("main.php?fightgodlobster=1");
$skill[Saucegeyser].use_skill();
print("The last choice number was " + last_choice());
// NOTE LACK OF VISIT CHOICE.PHP
run_choice(1);
print("The last choice number was " + last_choice());

abort("Complete.");

Method: I set Mafia automatic handling of the choice to 2 > I visit the choice > I fight the Lobster.
Automatic handling of which choice? 1310, the God Lobster choice?

If I visit LOVE Tunnel, it submits a value for the choice. Then it breaks because it tried to run_choice(1) AFTER it's already completed the choice. Hence "Encountered choice adventure with no choices. ".
Maybe. Looking at RuntimeLibrary.run_choice():

Code:
			// Submit the option chosen
			String message = "Submitting option " + option + " for choice " + ChoiceManager.getLastChoice();
			RequestLogger.printLine( message );

			// If want to handle fights via CCS, use ChoiceManager.CHOICE_HANDLER
			if ( handleFights )
			{
				response = ChoiceManager.processChoiceAdventure( option, extraFields, false );
			}
			// Otherwise, submit it in a new GenericRequest
			else
			{
				GenericRequest request = new GenericRequest( "choice.php" );
				request.addFormField( "whichchoice", String.valueOf( ChoiceManager.lastChoice ) );
				request.addFormField( "option", String.valueOf( decision ) );
...
				request.addFormField( "pwd", GenericRequest.passwordHash );
				request.run();
				response = request.responseText;
			}
It is run_choice() which prints the ""Submitting option 2 for choice 1222" line.
And it is ChoiceManager.processChoiceAdventure which prints the ""Encountered choice adventure with no choices."
So it is automating your choice, which is the default for run_choice( # ).
You could make it submit the choice and not try to automate it with run_choice( 2, false ).

Would it help if I ran my script using Lyle as the escape_choice() stuff? Today I used the LOVE Tunnel version, and it was fine, as expected.
Maybe. The key thing is that after doing run_combat(), you do visit_url( "choice.php" ). At which point, run_choice( 2 ) would work as expected.

I will mention that currently, KoLmafia's "last_choice()" function tells you the last choice it has seen. It is NOT useful to see if you are currently in a choice.

The current paradigm:

Code:
visit_url();
run_combat();
if ( choice_follows_fight() ) {
    visit_url( "choice.php" );
    run_choice( 2 );
}
COULD be simplified to:

Code:
visit_url();
run_combat();
run_choice(2);
If we made a change to run_choice:

Code:
if ( we are not currently in a choice but choice follows combat ) {
    visit_url( "choice.php" )
}
and THEN submit the URL with the current "last_choice()" and the specified option.

That is probably harmless, since if there are, say, several possible choices, you could still do

Code:
if ( choice_follows_combat() ) {
    visit_url( "choice.php" );
   ... look at last_choice() and decide which option to use.
   .. or even look at available_choice_options() to see which ones are available.
}
Which option to use to fight a tentacle at the science tent varies, so you have to do something like that last block to figure out which one to use.

I may make that change to run_choice(), but everything you've shown me so far says that if you call visit_url( "choice.php" ) after your run_combat(), you'll be fine. Preferably ONLY if choice_follows_fight(), since you CAN lose to the God Lobster and not be given the choice.

For amusement, here is MY farming script's function that handles the God Lobster:

Code:
void god_lobster_fights()
{
    if ( !have_god_lobster ) {
	return;
    }

    int fights = 3 - get_property( "_godLonsterFights" ).to_int();
    if ( fights <= 0 ) {
	return;
    }

    // Neither Meat Drop nor Item Drop matters for these fights.
    // Put on something, at least.
    outfit( farm_outfit );
    use_familiar( GOD_LOBSTER );

    // First goal is to acquire all the pieces of regaila.  Once you
    // have them all, equip the crown and choose "experience", which
    // will also give you a dish of clarified butter
    while ( fights > 0 && my_adventures() > 0 ) {
	// Choose which item to equip
	int scepters = available_amount( GOD_LOBSTER_SCEPTER );
	int rings = available_amount( GOD_LOBSTER_RING );
	int rods = available_amount( GOD_LOBSTER_ROD );
	int robes = available_amount( GOD_LOBSTER_ROBE );
	int crowns = available_amount( GOD_LOBSTER_CROWN );
	item familiar_item =
	    ( crowns > 0 ) ? GOD_LOBSTER_CROWN :
	    ( robes > 0 ) ? GOD_LOBSTER_ROBE :
	    ( rods > 0 ) ? GOD_LOBSTER_ROD :
	    ( rings > 0 ) ? GOD_LOBSTER_RING :
	    ( scepters > 0 ) ? GOD_LOBSTER_SCEPTER :
	    NO_ITEM;
    
	// If unspecified, use whatever the familiar is already wearing
	if ( familiar_item != NO_ITEM ) {
	    equip( familiar_item );
	}

	between_battle_checks();
	string page = visit_url( "main.php?fightgodlobster=1" );
	if ( !page.contains_text( "fight.php" ) ) {
	    // Unexpected
	    break;
	}

	combat_filter_setup( NO_LOCATION );
	page = run_combat( "default_filter" );
	fights--;

	if ( !page.contains_text( "choice.php" ) ) {
	    // Unexpected. Perhaps you lost the fight?
	    continue;
	}

	page = visit_url( "choice.php" );

	// Options 1, 2, or 3 - unless you are wearing the crown, in
	// which case the "regalia" option is not available and the
	// others are 1 and 2. We'll go for "experience"
	// 
	// "I'd like part of your regalia."
	// "I'd like a blessing."
	// "I'd like some experience."

	int option = ( familiar_item == GOD_LOBSTER_CROWN ) ? 2 : 1;
	run_choice( option );
    }
}
 

Malibu Stacey

Active member
Why are we trying to debug what happens when you do not call "choice.php" after the fight but before run_choice(#)?
A correct script will do something like "if ( choice_follows_fight() ) visit_url( "choice.php" )".

I've literally never had this work but I suspect it's because I script adventuring in regular locations using adv1() rather than adventure().
 

Veracity

Developer
Staff member
I've literally never had this work but I suspect it's because I script adventuring in regular locations using adv1() rather than adventure().
I'll try that out.

Assuming that I can come up with a monster in such a location that gives you a choice adventure when you defeat it; that is the only situation in which choice_follows_fight() is meaningful.
 
Last edited:

Aenimus

Member
Alright, I ran a snippet of farming script:

Code:
script "test69420.ash";

import "aen_resources.ash";

while (my_inebriety() < inebriety_limit() + 1) {
	set_property("choiceAdventure1310", 0);
	
	// LOVE Tunnel
	if (lov_can()) {
		lov_run();
		continue;
	}
	
	// @TODO file clean up for skill juggling
	if (witchess_fight_can()) {
		witchess_fight_run();
		cli_execute("terminal educate digitize");
		cli_execute("terminal educate extract");
		continue;
	}

	// Lynyrds @TODO file
	if (get_property("_lynyrdSnareUses").to_int() < 3) {
		print("Fighting free lynyrd.", "green");
		$item[lynyrd snare].use();
		continue;
	}

	// God Lobster
	if (globster_can()) {
		globster_run(5, 2);
		continue;
	}
}

And this happened:

> test69420.ash

Running the LOVE Tunnel with the goals of LOV Earrings, Open Heart Surgery and LOV Enamorang.
Preference lastAdventure changed from The Barrel Full of Barrels to The Tunnel of L.O.V.E.

[2144] The Tunnel of L.O.V.E.
Preference lastEncounter changed from L.O.V. Emporium (#1228) to The Tunnel of L.O.V.E. (#1222)
Encounter: The Tunnel of L.O.V.E. (#1222)
Submitting option 1 for choice 1222

[2144] The Tunnel of L.O.V.E.
...
This combat did not cost a turn

[2144] The Tunnel of L.O.V.E.
...
Submitting option 3 for choice 1224

[2144] The Tunnel of L.O.V.E.
...
This combat did not cost a turn

[2144] The Tunnel of L.O.V.E.
...
Submitting option 2 for choice 1226

[2144] The Tunnel of L.O.V.E.
...
This combat did not cost a turn

[2144] The Tunnel of L.O.V.E.
...
You acquire an item: LOV Enamorang

Preparing to fight a Witchess Knight.
Preference lastAdventure changed from The Barrel Full of Barrels to None
Preference nextAdventure changed from The Tunnel of L.O.V.E. to None

...

[2144] Your Witchess Set
...
This combat did not cost a turn
Preference lastAdventure changed from None to The Barrel Full of Barrels
Source Terminal: educate digitize.edu
Preference sourceTerminalEducate1 changed from extract.edu to digitize.edu
Source Terminal used.
Source Terminal: educate extract.edu
Preference sourceTerminalEducate1 changed from digitize.edu to extract.edu
Source Terminal used.
Taking Crawdaunt the God Lobster out of terrarium...
Preference _godLobsterFights changed from 0 to 1
Preference lastAdventure changed from The Barrel Full of Barrels to None

...

[2144] God Lobster
Preference lastEncounter changed from Witchess Knight to the God Lobster
Encounter: the God Lobster
Preference _lastCombatStarted changed from 20200229153100 to 20200229153108
...

This combat did not cost a turn
Unsupported choice adventure #1191
choice 1: (secret choice)
Click here to continue in the relay browser.

You're on your own, partner.

globster_run() is the same as previously declared (visits choice.php). Note that the escape_choice() stuff is not included, and Mafia stalls on the Globster. 1191 is the Source Terminal.
 

Veracity

Developer
Staff member
Code:
Source Terminal: educate digitize.edu
Source Terminal used.
Source Terminal: educate extract.edu
Source Terminal used.
...

[2144] God Lobster
Encounter: the God Lobster
...
This combat did not cost a turn
// *** Here it is choice_follows_fight().
// *** This is the time to visit_url( "choice.php" );
Unsupported choice adventure #1191
choice 1: (secret choice)
Click here to continue in the relay browser.
// *** This is the output you'd expect from run_choice( 2 ) if last_choice() == 1191
// *** visit_url( "choice.php" ) would have printed other output and changed last_choice()
I conclude that visit_url( "choice.php" ) was NOT called.

OK. Here is my test script which will visit the source terminal and run one fight with the God Lobster.

Code:
void globster()
{
    int fights = get_property( "_godLonsterFights" ).to_int();
    print( "You have challenged the God Lobster " + fights + " times today." );
    if ( fights >= 3 ) {
	print( "That's enough." );
	return;
    }

    use_familiar( $familiar[ God Lobster ] );
    equip( $item[ God Lobster's Crown ] );
    restore_hp( 0 );
    restore_mp( 0 );

    print( "Challenging the God Lobster." );
    string page = visit_url("main.php?fightgodlobster=1");
    if ( !page.contains_text( "fight.php" ) ) {
	print( "No fight. Are you out of challenges?" );
	return;
    }
    print( "Fight! Fight! Fight!" );
    run_combat();
    if ( choice_follows_fight() ) {
	print( "Choice. You must have won the fight. Congratulations!" );
	print( "Immediately after fight: last_choice = " + last_choice() );
	visit_url("choice.php");
	print( "After visiting choice.php: last_choice = " + last_choice() );
	print( "Asking for experience." );
	run_choice( 2 );
    } else {
	print( "No choice. You must have lost the fight." );
    }
}

void main()
{
    cli_execute("terminal educate extract");
    cli_execute("terminal educate digitize");
    globster();
}
Visits the source terminal.
Verbose logging.

Here is the result of running it:

Code:
[color=green]> globster-test.ash[/color]

Source Terminal: educate extract.edu
Source Terminal used.
Source Terminal: educate digitize.edu
Source Terminal used.
You have challenged the God Lobster 0 times today.
Putting Hasemary the Trick-or-Treating Tot back into terrarium...
Taking SnickClackClaackSnackClack the God Lobster out of terrarium...
Challenging the God Lobster.

[1789] God Lobster
Encounter: the God Lobster
Round 0: Veracity loses initiative!
Round 1: You lose 7 hit points
Fight! Fight! Fight!
Round 1: Veracity executes a macro!
Round 1: Veracity casts SAUCEGEYSER!
Round 2: God Lobster takes 193 damage.
Round 2: God Lobster takes 1 damage.
Round 2: You lose 26 hit points
Round 2: Veracity casts SAUCEGEYSER!
Round 3: God Lobster takes 349 damage.
Round 3: Veracity wins the fight!
After Battle: You gain 57 Beefiness
After Battle: You gain 54 Enchantedness
You gain a Mysticality point!
After Battle: You gain 164 Roguishness
This combat did not cost a turn
Choice. You must have won the fight. Congratulations!
Immediately after fight: last_choice = 1191

[1789] God Lobster
Encounter: Granted a Boon
After visiting choice.php: last_choice = 1310
Asking for experience.
Submitting option 2 for choice 1310
You gain 500 Strengthliness
You gain a Muscle point!
You gain 500 Mysteriousness
You gain a Mysticality point!
You gain 800 Sarcasm
You gain a Moxie point!
You acquire an item: Dish of Clarified Butter
Notice the difference between my log and your log:

I had:

Code:
This combat did not cost a turn
Choice. You must have won the fight. Congratulations!
Immediately after fight: last_choice = 1191

[1789] God Lobster
Encounter: Granted a Boon
After visiting choice.php: last_choice = 1310

You had:

Code:
This combat did not cost a turn
Unsupported choice adventure #1191
Visiting choice.php logs the choice encounter and changes last_choice().
Your log did not show that.
Conclusion: your script did not visit choice.php
 

Aenimus

Member
I just realised that I sent you the wrong definition of globster_run(), so here it is:

Code:
boolean globster_run(int eqp, int option) {
	if (eqp < 0 || eqp > 5) abort("Equipment specification out of bounds.");
	if (eqp == 5 && option > 2) option = 2;
	int fights = globster_fights();
	$familiar[God Lobster].use();
	repeat {
		if (globster_equipment[eqp].try_equip()) break;
		eqp--;
		option = 1;
	} until (eqp == 0);
	visit_url("main.php?fightgodlobster=1");
	run_combat();
	visit_url("choice.php", false);
	run_choice(option);
	visit_url("main.php", false);
	return fights < globster_fights();
}

The only meaningful difference is the false part of the visit_url(), I think.

I still don't understand how it wouldn't visit choice.php. It's written right there. And this doesn't explain why it works if I "escape the choice". Because if it were never visiting choice.php, why would it work 100% of the time when I "escape the choice"?

Logical conclusions:
1. it's not visiting choice.php, and it should break no matter what (not the case)

2. it's not visiting choice.php, but doesn't break with the LOVE Tunnel for some reason (can you explain why?)

3. it's visiting choice.php and something else is causing it to break
 
Last edited:

Aenimus

Member
I stuck escape_choice() after the source terminal cli_executes:

...
[2144] God Lobster
Preference lastEncounter changed from The Tunnel of L.O.V.E. (#1222) to the God Lobster
...
This combat did not cost a turn

[2144] God Lobster
Preference lastEncounter changed from the God Lobster to Granted a Boon (#1310)
Encounter: Granted a Boon (#1310)
Submitting option 2 for choice 1310
Encounter: Granted a Boon (#1310)
You gain 625 Muscleboundness
You gain 625 Magicalness
You gain 675 Smarm
You acquire an item: Dish of Clarified Butter
Preference _godLobsterFights changed from 1 to 2
 

Veracity

Developer
Staff member
The difference is the false part of the visit_url(), I think.
OK. "false" means use GET rather than POST. Don't do that! :)

It don't understand how it wouldn't visit choice.php. It's written right there.
Presumable it does visit it - with a GET - and KoL doesn't return the expected thing.

Code:
And this doesn't explain why it works if I "escape the choice". Because if it were never visiting choice.php, why would it work 100% of the time when I "escape the choice"?
Because you are going elsewhere and calling choice.php with POST, using run_choice().

OK. Since this seems to be causing trouble, I will change run_choice() to do this:

- If you are in a "choice follows fight" situation, you have not visited "choice.php" yet. Visit it.
- If we are not handling a choice, return the response from the last choice (as before)
- If we are handling a choice (perhaps because we visited choice.php above), submit the requested option.

Note that the previous paradigm still works: after a fight, you can submit choice.php - and last_choice() and available_choice_options() will be accurate.
But, if you KNOW what choice you will get and KNOW which (available) option you want, you can omit visiting choice.php with a POST.
 

Veracity

Developer
Staff member
OK.

I added a new ASH function:

boolean handling_choice()

Returns true if you are currently in a choice and last_choice() and available_choice_options() are accurate for the choice.

1) I changed globster-test.ash to have this:

Code:
    if ( choice_follows_fight() ) {
	print( "Choice. You must have won the fight. Congratulations!" );
	print( "Immediately after fight: last_choice = " + last_choice() + " handling choice = " + handling_choice() );
	visit_url("choice.php");
	print( "After visiting choice.php: last_choice = " + last_choice() + " handling choice = " + handling_choice() );
	print( "Asking for experience." );
	run_choice( 2 );
    } else {
	print( "No choice. You must have lost the fight." );
    }
And, using the new function, I get this:

Code:
This combat did not cost a turn
Choice. You must have won the fight. Congratulations!
Immediately after fight: last_choice = 1191 handling choice = false

[1789] God Lobster
Encounter: Granted a Boon
After visiting choice.php: last_choice = 1310 handling choice = true
Asking for experience.
Submitting option 2 for choice 1310

2) I changed run_choice() to detect if choice_follows_fight() and, if so, to POST choice.php for you before submitting the choice option.

I changed globster-test.ash to have this:

Code:
    if ( choice_follows_fight() ) {
	print( "Choice. You must have won the fight. Congratulations!" );
	print( "Immediately after fight: last_choice = " + last_choice() + " handling choice = " + handling_choice() );
	// visit_url("choice.php");
	// print( "After visiting choice.php: last_choice = " + last_choice() + " handling choice = " + handling_choice() );
	print( "Asking for experience." );
	run_choice( 2 );
    } else {
	print( "No choice. You must have lost the fight." );
    }
And, NOT manually POSTing choice.php before run_choice(), I get this:

Code:
This combat did not cost a turn
Choice. You must have won the fight. Congratulations!
Immediately after fight: last_choice = 1191 handling choice = false
Asking for experience.

[1789] God Lobster
Encounter: Granted a Boon
Submitting option 2 for choice 1310
Revision 19788.

This should solve your issues; you were not correctly using the existing paradigm, but there is an additional (new) paradigm which can be used in simpler use cases, which are apparently what you (and others) seem to expect. :)
 
Top