Feature - Implemented choiceAdventureScript

Veracity

Developer
Staff member
I have to ask for another debug log, please.

I want to see what happens when you submit the run_choice() from 1024.
I expect to see the choice redirect to fight.php.
(considering the script does a run_combat(), that seems likely).

If I recall, you submitted this with adv1()?

Yeah. I made that follow "multi-fight" chains and "choice follow fight" chains, but, a "fight follows choice" is a redirect.
Let me look at that...
 

Veracity

Developer
Staff member
What confuses me is that my ChoiceAdventureTest.ash script returns after every choice that it handles with run_choice().
As I mentioned before:

It handles The Gourd!, which is a chain of choice => 6 fights => choice => 6 fights => choice => 6 fights => choice => 1 fight => choice
I kicked that off by selecting 1 adventure in The Gourd! via the GUI - which is what adv1() does.
It did all the choices and fights before executing a post-adventure script on the way out.

I don't see how that is conceptually different than
fight (die) => choice 1023 => choice 1024 => fight (die ) => choice 1023 => choice 1024 => fight ...

That is fight => choice (chain) => fight => choice (chain) => fight ...
 

Veracity

Developer
Staff member
OK.

We have:

in_multi_fight() - The last round of a fight (win or lose) has a link to fight.php for another fight
choice_follows_fight() - The last round of a fight (win or lose) has a link to choice.php

We don't have:

fight_follows_choice() - A choice redirects to a fight.

We need that. As coded, if we are automating choices, if we submit the choice and get redirected, the fight gets automated at a lower level and returns.
Instead, if a choice redirects to a fight, that should be the end of the automation for the chiice and the next level up should automate the fight.

This will require some careful thought.
 

Veracity

Developer
Staff member
Here is what I gleaned from your log, removing the 75% of it which was Guide updates and picking out only the significant parts.

This shows that when you left the Underworld Like a Bat out of Hell (as directed by auto_choice_adv.ash), it sent you right back into a fight and it was only after that fight finished that we returned from run_choice() and your choice adventure script exited.

That's the issue I sketched out in my last note.

Code:
Visit to McLarge: The Goatlet in progress...

class net.sourceforge.kolmafia.request.AdventureRequest
Requesting: https://www.kingdomofloathing.com/adventure.php?snarfblat=271
Retrieved: https://www.kingdomofloathing.com/adventure.php?snarfblat=271
Field: Location = [fight.php?ireallymeanit=1585865956]

class net.sourceforge.kolmafia.request.FightRequest
Requesting: https://www.kingdomofloathing.com/fight.php?ireallymeanit=1585865956
Retrieved: https://www.kingdomofloathing.com/fight.php?ireallymeanit=1585865956

[201] The Goatlet
Encounter: dairy goat
Round 0: PlayerTwo loses initiative!
Round 1: dairy goat takes 3 damage.
Parsing result: You lose 48 hit points
Round 1: You lose 48 hit points
Processing result:  HP: -48
This combat did not cost a turn
Preference _edDefeats changed from 0 to 1

class net.sourceforge.kolmafia.request.GenericRequest
Requesting: https://www.kingdomofloathing.com/choice.php
Retrieved: https://www.kingdomofloathing.com/choice.php
Preference lastEncounter changed from dairy goat to Like a Bat Into Hell
Encounter: Like a Bat Into Hell
Processing results...
Parsing result: You gain 41 hit points
You gain 41 hit points
Processing result:  HP: 41

Starting choice adventure script: auto_choice_adv.ash
Submitting option 1 for choice 1023

class net.sourceforge.kolmafia.session.ChoiceManager$1
Requesting: https://www.kingdomofloathing.com/choice.php?whichchoice=1023&option=1&pwd
Retrieved: https://www.kingdomofloathing.com/choice.php?whichchoice=1023&option=1&pwd

class net.sourceforge.kolmafia.request.GenericRequest
Requesting: https://www.kingdomofloathing.com/place.php?whichplace=edunder
Retrieved: https://www.kingdomofloathing.com/place.php?whichplace=edunder

<font color="blue">[INFO] - Ed died in combat 1 time(s)</font>
<font color="red">[INFO] - Time to shop!</font>
<font color="green">[INFO] - Buying Holy Spring Water</font>

class net.sourceforge.kolmafia.request.GenericRequest
Requesting: https://www.kingdomofloathing.com/shop.php?pwd&whichshop=edunder_shopshop&action=buyitem&quantity=1&whichrow=436
Retrieved: https://www.kingdomofloathing.com/shop.php?pwd&whichshop=edunder_shopshop&action=buyitem&quantity=1&whichrow=436

You acquire an item: holy spring water
Processing result: holy spring water
Processing result: Ka coin (-1)

class net.sourceforge.kolmafia.request.GenericRequest
Requesting: https://www.kingdomofloathing.com/place.php?whichplace=edunder&action=edunder_leave
Retrieved: https://www.kingdomofloathing.com/place.php?whichplace=edunder&action=edunder_leave
Field: Location = [choice.php?forceoption=0]

Requesting: https://www.kingdomofloathing.com/choice.php?forceoption=0
Retrieved: https://www.kingdomofloathing.com/choice.php?forceoption=0

Preference lastEncounter changed from Like a Bat Into Hell to Like a Bat out of Hell
Encounter: Like a Bat out of Hell
Finished choice adventure script: auto_choice_adv.ash

Starting choice adventure script: auto_choice_adv.ash
Submitting option 1 for choice 1024
class net.sourceforge.kolmafia.session.ChoiceManager$1
Processing result: Ka coin (0)

Requesting: https://www.kingdomofloathing.com/choice.php?whichchoice=1024&option=1&pwd
Field: Location = [fight.php?ireallymeanit=1585865963]

class net.sourceforge.kolmafia.request.FightRequest
Requesting: https://www.kingdomofloathing.com/fight.php?ireallymeanit=1585865963
Retrieved: https://www.kingdomofloathing.com/fight.php?ireallymeanit=1585865963

Preference lastEncounter changed from Like a Bat out of Hell to dairy goat
Encounter: dairy goat
Preference _lastCombatStarted changed from 20200402221913 to 20200402221920
Round 0: PlayerTwo loses initiative!
Round 1: dairy goat takes 4 damage.
Parsing result: You lose 48 hit points
Round 1: You lose 48 hit points
Processing result:  HP: -48
This combat did not cost a turn
Preference _edDefeats changed from 1 to 2

Finished choice adventure script: auto_choice_adv.ash

Unsupported choice adventure #1024
<b>choice 1</b>: Return to the fight!
<b>choice 2</b>: Return to your tomb. (1)
<b>choice 3</b>: Not just yet
<a href=main.php target=mainpane class=error>Click here to continue in the relay browser.</a><br>

class net.sourceforge.kolmafia.request.GenericRequest
Requesting: https://www.kingdomofloathing.com/choice.php
Retrieved: https://www.kingdomofloathing.com/choice.php

Preference lastEncounter changed from dairy goat to Like a Bat Into Hell
Encounter: Like a Bat Into Hell
Processing results...
Parsing result: You gain 41 hit points
You gain 41 hit points
Processing result:  HP: 41

Stack trace:
  at autoAdv (auto_adventure.ash:77)
  at L8_trapperGround (auto_mclargehuge.ash:40)
  at LM_edTheUndying (auto_edTheUndying.ash:1441)
  at doTasks (autoscend.ash:5915)
  at auto_begin (autoscend.ash:6205)
  at safe_preference_reset_wrapper (autoscend.ash:6274)
  at safe_preference_reset_wrapper (autoscend.ash:6281)
  at safe_preference_reset_wrapper (autoscend.ash:6281)
  at safe_preference_reset_wrapper (autoscend.ash:6281)
printStackOnAbort => false

Finished ASH script: autoscend.ash
 

Malibu Stacey

Active member
OK.

We have:

in_multi_fight() - The last round of a fight (win or lose) has a link to fight.php for another fight
choice_follows_fight() - The last round of a fight (win or lose) has a link to choice.php

We don't have:

fight_follows_choice() - A choice redirects to a fight.

We need that. As coded, if we are automating choices, if we submit the choice and get redirected, the fight gets automated at a lower level and returns.
Instead, if a choice redirects to a fight, that should be the end of the automation for the chiice and the next level up should automate the fight.

This will require some careful thought.

You might be able to test this in the Haunted Bedroom. The Animated rustic nightstand has a choice named "Investigate the jewelry" which puts you in a combat.

Thanks for all the effort on this Veracity, it is very much appreciated.
 

Veracity

Developer
Staff member
I have it figured out. I tested it in the Spooky Forest, which has a choice chain which leads to fighting a spooky vampire.

OK. We already had an alternate version of run_choice() which did what the ASH script needs.

string run_choice( int option )
string run_choice( int option, boolean automateFIghts )

The first version calls run_choice( option, true )

Therefore, if the choice redirects to a fight, we run the fight before that call to run_choice() returns.
Now, if you call run_choice( -1 ), you are saying "go to goal" - follow a sequence of choices. If that ends in a fight, we automate it.
But if you KNOW the choice you are submitting ends in a fight, if you call run_choice ( X, false ), it will return after getting the redirection and taking it - getting the Round 0 fight page.
run_choice() then returns.

I added fight_follows_choice() for this case, and you can then call run_combat().

Or, if you kicked this off with adv1() or adventure() and your choiceAdventureScript() handled the choices, adv1() or adventure() will automate the fight.

I modified my ChoiceAdventureTest.ash to do this in the spooky forest.

Test 1: Spooky Forest (with choiceAdventureScript), goal = 1 choice, 10 turns:

Code:
[1082813] The Spooky Forest
Encounter: Arboreal Respite
> In choice adventure 502
Took choice 502/2: gain mosquito larva or spooky mushrooms, skip adventure, get stats or fight a vampire
choice.php?whichchoice=502&option=2&pwd
Encounter: Consciousness of a Stream
> Done!
> In choice adventure 505
Took choice 505/3: fight a spooky vampire
choice.php?whichchoice=505&option=3&pwd
Encounter: An Interesting Choice
> Done!
> In choice adventure 46
Took choice 46/3: vampire heart
choice.php?whichchoice=46&option=3&pwd
Encounter: spooky vampire
Round 0: Chondara wins initiative!
> Heading into a fight...
> Done!
Round 1: Chondara executes a macro!
Round 1: Chondara attacks!
Round 2: spooky vampire takes 4402 damage.
Round 2: Silence climbs up and sits on your shoulder, and hands you some Meat. Huh, where did he find that?
You gain 57 Meat.
Round 2: Chondara wins the fight!
After Battle: Silence sits on your fallen opponent's body, blows a smoke ring, and winks at you.
You gain 36 Meat
After Battle: You gain 2 Wizardliness
After Battle: You gain 2 Smarm
Notice that my choceAdventureScript was called 3 times - choice 502, 505, 46. For 46, after it submitted the choice, fight_follows_choice() was true. My script exited, adventuring finished off the fight, and the goal was met.

I then set auto-attack to "attack" to see what happens when the fight was fought and won immediately.

Code:
[1082819] The Spooky Forest
Encounter: Arboreal Respite
> In choice adventure 502
Took choice 502/2: gain mosquito larva or spooky mushrooms, skip adventure, get stats or fight a vampire
choice.php?whichchoice=502&option=2&pwd
Encounter: Consciousness of a Stream
> Done!
> In choice adventure 505
Took choice 505/3: fight a spooky vampire
choice.php?whichchoice=505&option=3&pwd
Encounter: An Interesting Choice
> Done!
> In choice adventure 46
Took choice 46/3: vampire heart
choice.php?whichchoice=46&option=3&pwd
Encounter: spooky vampire
Round 0: Chondara wins initiative!
Round 0: Chondara attacks! (auto-attack)
Round 1: spooky vampire takes 4390 damage.
Round 1: Chondara wins the fight!
After Battle: Silence sits on your fallen opponent's body, blows a smoke ring, and winks at you.
You gain 17 Meat
After Battle: You gain 1 Beefiness
After Battle: You gain 2 Enchantedness
> Done!
Notice that my script submitted run_choice(), which redirected to the fight, which was instantly over. fight_follows_choice() was NOT true, and the choiceAdventureScript exited after the fight was over.

I just tested this with The Gourd! and it worked fine. I adjusted my ChoiceAdventureScript so that all the various stages that led to a fight called run_choice( X, false). I told the GUI to adventure for 1 turn in The Gourd! and it did the whole thing, just as before.

Revision 19953 has this. Your change is to NOT do run_combat() in your choiceAdventureScript after you tell it to return to the fight. Instead, call run_choice( 1, false ) and let adv1 resume the fight for you. Hopefully, that will work even if Ed dies again in the second and third fights.

FYI, here is my modified test script.

Code:
void main( int choice, string page )
{
    // code to handle the choice, using available_choice_options(), run_choice(), etc.
    print( "In choice adventure " + choice );

    int option = 0;
    boolean fight = false;
    switch ( choice ) {
	// The Spooky Forest
    case 26:	// A Three-Tined Fork
	// 1 => 27, 2 => 28, 3 => 29
	option = 2;
	break;
    case 27:	// Footprints
	// 1 => Seal Clubber, 2 => Turtle Tamer
	option = 2;
	break;
    case 28:	// A Pair of Craters
	// 1 => Pastamancer, 2 => Sauceror
	option = 2;
	break;
    case 29:	// The Road Less Visible
	// 1 => Disco Bandit, 2 => Accordion Thief
	option = 2;
	break;
    case 46:	// An Interesting Choice
	// 1 => mysticality, 2 => Muscle, 3 => fight
	option = 3;
	fight = true;
	break;
    case 47:	// Have a Heart
	// 1 => give hearts, 2 => exit choice
	option = 1;
	break;
    case 502:	// Arboreal Respite
	// 1 => 503, 2 => 505, 3 => 506
	option = 2;
	break;
    case 503:	// The Road Less Traveled
	// 1 => Meat, 2 => wooden stakes or 47, 3 => 504
	option = 1;
	break;
    case 504:	// Tree's Last Stand
	// 1, 2, 3 => (buy or sell) and stay in 504, 4 => exit choice
	option = 4;
	break;
    case 505:	// Consciousness of a Stream
	// 1 => mosquito larva or 3 spooky mushrooms, 2 => tree-holed coin or nothing, 3 => 46
	option = 3;
	break;
    case 506:	// Through Thicket and Thinnet
	// 1 => 26, 2 => Spooky-Gro fertilizer, 3 => 507
	option = 1;
	break;
    case 507:	// O Lith, Mon
	// 1 => Spooy Temple map, 2 => exit choice, 3 => exit choice
	option = 1;
	break;

	// The Gourd!
    case 619:	// To Meet a Gourd
    case 620:	// A Blow is Struck!
    case 621:	// Hold the Line!
    case 622:	// The Moment of Truth
	// The following occur if you leave the battle and return
    case 623:	// Return To the Fray!
    case 624:	// Returning to Action
	// All of the above lead to a fight
	fight = true;
    case 634:	// Goodbye Fnord
	option = 1;
	break;

	// The Haunted Bedroom
    case 876:	// One Simple Nightstand
    case 877:	// One Mahogany Nightstand
    case 878:	// One Ornate Nightstand
    case 879:	// One Rustic Nightstand
	option = 1;
	break;
    case 880:	// One Elegant Nightstand
	option = 2;
	break;

    default:
	print( "not handling " + choice );
	return;
    }

    // Argument 2 is "should automate fights" We don't want to do that
    // inside this script; follow the redirect and leave it to outer
    // automation.
    run_choice( option, !fight );
    if ( fight_follows_choice() ) {
	print( "Heading into a fight..." );
    }
    print( "Done!" );
}
 

Malibu Stacey

Active member
Revision 19953 has this. Your change is to NOT do run_combat() in your choiceAdventureScript after you tell it to return to the fight. Instead, call run_choice( 1, false ) and let adv1 resume the fight for you. Hopefully, that will work even if Ed dies again in the second and third fights.

You are an actual legend Veracity. I shall go start day 2 of my Ed test run with 19953.

Again thanks for all the work on this.
 

Malibu Stacey

Active member
Testing on day 2 of my Ed run looked pretty good. It ran through what it had left of the level 8 quest (1 more level of extremity then the Mist-Shrouded Peak), the level 9 quest (except A-boo Clues), all of the level 10 quest and all of Spookyraven first and second floors. No unexpected aborts.
 

Veracity

Developer
Staff member
Super! I'll give you a few more days of Ed and, if you have no issues, I'll mark this Implemented again.
 

Malibu Stacey

Active member
Spoke too soon.

Code:
[24] Hippy Camp
Preference lastEncounter changed from crusty hippy Vegan chef to dirty hippy
Encounter: dirty hippy
Preference _lastCombatStarted changed from 20200405180904 to 20200405180913
Round 0: PlayerTwo loses initiative!
Round 1: You lose 1 hit point
Round 1: You lose 42 hit points
This combat did not cost a turn
Preference _edDefeats changed from 0 to 1
Preference lastEncounter changed from dirty hippy to Like a Bat Into Hell
Encounter: Like a Bat Into Hell
You gain 11 hit points
Submitting option 1 for choice 1023
[INFO] - Ed died in combat 1 time(s)
[INFO] - Time to shop!
mummified beef haunch is not multiusable, but KoLmafia thought it was
You acquire an item: mummified beef haunch
[INFO] - Buying a mummified beef haunch!
Preference lastEncounter changed from Like a Bat Into Hell to Like a Bat out of Hell
Encounter: Like a Bat out of Hell
Submitting option 1 for choice 1024
Preference lastEncounter changed from Like a Bat out of Hell to dirty hippy
Encounter: dirty hippy
Preference _lastCombatStarted changed from 20200405180913 to 20200405180920
Round 0: PlayerTwo loses initiative!
Round 1: You lose 1 hit point
Round 1: You lose 41 hit points
This combat did not cost a turn
Preference _edDefeats changed from 1 to 2
Unsupported choice adventure #1024
choice 1: Return to the fight!
choice 2: Return to your tomb. (1)
choice 3: Not just yet
Click here to continue in the relay browser.

Preference lastEncounter changed from dirty hippy to Like a Bat Into Hell
Encounter: Like a Bat Into Hell
You gain 11 hit points

Encounter: Like a Bat Into Hell

That last line is after I clicked on the main map in the relay browser to refresh the page (stripped out some autoscend call stacks and other spam at the end there). The weird thing is, where it says "Unsupported choice adventure #1024", it can't actually be in 1024 at that point, it's in 1023 and it's not recognising it as there's no "Submitting option 1 for choice 1023" line.

I'll try to reproduce with a debug log. Might take a while though as it's intermittent (this was after 23 adventures in my new run).

Code:
> version

KoLmafia v20.3 r19965
 
Last edited:

Veracity

Developer
Staff member
Code:
class net.sourceforge.kolmafia.request.AdventureRequest
Requesting: https://www.kingdomofloathing.com/adventure.php?snarfblat=26
Retrieved: https://www.kingdomofloathing.com/adventure.php?snarfblat=26
Field: Location = [fight.php?ireallymeanit=1586118536]
class net.sourceforge.kolmafia.request.FightRequest
Requesting: https://www.kingdomofloathing.com/fight.php?ireallymeanit=1586118536
Retrieved: https://www.kingdomofloathing.com/fight.php?ireallymeanit=1586118536

[47] Hippy Camp
Encounter: filthy hippy jewelry maker
Round 0: Player Two loses initiative!
Round 1: You lose 1 hit point
Round 1: You lose 36 hit points
This combat did not cost a turn

class net.sourceforge.kolmafia.request.GenericRequest
Requesting: https://www.kingdomofloathing.com/choice.php
Retrieved: https://www.kingdomofloathing.com/choice.php
Encounter: Like a Bat Into Hell
You gain 19 hit points

Starting choice adventure script: auto_choice_adv.ash
Submitting option 1 for choice 1023
class net.sourceforge.kolmafia.session.ChoiceManager$1
Requesting: https://www.kingdomofloathing.com/choice.php?whichchoice=1023&option=1&pwd
Retrieved: https://www.kingdomofloathing.com/choice.php?whichchoice=1023&option=1&pwd
Field: location = [place.php?whichplace=edunder]
class net.sourceforge.kolmafia.request.GenericRequest
Requesting: https://www.kingdomofloathing.com/place.php?whichplace=edunder
Retrieved: https://www.kingdomofloathing.com/place.php?whichplace=edunder

<font color="blue">[INFO] - Ed died in combat 1 time(s)</font>
<font color="red">[INFO] - Time to shop!</font>
class net.sourceforge.kolmafia.request.GenericRequest
Requesting: https://www.kingdomofloathing.com/place.php?whichplace=edunder&action=edunder_leave
Retrieved: https://www.kingdomofloathing.com/place.php?whichplace=edunder&action=edunder_leave
Field: Location = [choice.php?forceoption=0]
Requesting: https://www.kingdomofloathing.com/choice.php?forceoption=0
Retrieved: https://www.kingdomofloathing.com/choice.php?forceoption=0
Encounter: Like a Bat out of Hell
Finished choice adventure script: auto_choice_adv.ash

Starting choice adventure script: auto_choice_adv.ash
Submitting option 1 for choice 1024
class net.sourceforge.kolmafia.request.GenericRequest
Requesting: https://www.kingdomofloathing.com/choice.php?whichchoice=1024&option=1&pwd
Retrieved: https://www.kingdomofloathing.com/choice.php?whichchoice=1024&option=1&pwd
Field: Location = [fight.php?ireallymeanit=1586118542]
Requesting: https://www.kingdomofloathing.com/fight.php?ireallymeanit=1586118542
Retrieved: https://www.kingdomofloathing.com/fight.php?ireallymeanit=1586118542
Encounter: filthy hippy jewelry maker
Preference _lastCombatStarted changed from 20200405202856 to 20200405202903
Round 0: Player Two loses initiative!
Round 1: You lose 1 hit point
Round 1: You lose 35 hit points
This combat did not cost a turn
Finished choice adventure script: auto_choice_adv.ash

Unsupported choice adventure #1024
<b>choice 1</b>: Return to the fight!
<b>choice 2</b>: Return to your tomb. (1)
<b>choice 3</b>: Not just yet
Interesting.

You went to the Hippy Camp (adventure.php)
It redirects to fight.php
You lost initiative and died immediately.

Redirects to choice 1023
Start choiceadventure script for 1023
choice adventure script handles it and goes to edunder_leave
Redirects to choice 1024
Finish choiceadventure script for 1023
Start chiceadventure script for 1024
submits choice
Redirects to fight.php
You lost initiative and died immediately.
Finish choice adventure script for 1024

And now we are in a choice_follows_fight situation but don't handle it correctly.

Pondering.
 

Veracity

Developer
Staff member
Try Revision 19968. Untested, since I can't think of anything other than Ed where this would happen. :)
 

Malibu Stacey

Active member
Code:
class net.sourceforge.kolmafia.request.AdventureRequest
Requesting: https://www.kingdomofloathing.com/adventure.php?snarfblat=26
Retrieved: https://www.kingdomofloathing.com/adventure.php?snarfblat=26
Field: Location = [fight.php?ireallymeanit=1586118536]
class net.sourceforge.kolmafia.request.FightRequest
Requesting: https://www.kingdomofloathing.com/fight.php?ireallymeanit=1586118536
Retrieved: https://www.kingdomofloathing.com/fight.php?ireallymeanit=1586118536

[47] Hippy Camp
Encounter: filthy hippy jewelry maker
Round 0: Player Two loses initiative!
Round 1: You lose 1 hit point
Round 1: You lose 36 hit points
This combat did not cost a turn

class net.sourceforge.kolmafia.request.GenericRequest
Requesting: https://www.kingdomofloathing.com/choice.php
Retrieved: https://www.kingdomofloathing.com/choice.php
Encounter: Like a Bat Into Hell
You gain 19 hit points

Starting choice adventure script: auto_choice_adv.ash
Submitting option 1 for choice 1023
class net.sourceforge.kolmafia.session.ChoiceManager$1
Requesting: https://www.kingdomofloathing.com/choice.php?whichchoice=1023&option=1&pwd
Retrieved: https://www.kingdomofloathing.com/choice.php?whichchoice=1023&option=1&pwd
Field: location = [place.php?whichplace=edunder]
class net.sourceforge.kolmafia.request.GenericRequest
Requesting: https://www.kingdomofloathing.com/place.php?whichplace=edunder
Retrieved: https://www.kingdomofloathing.com/place.php?whichplace=edunder

<font color="blue">[INFO] - Ed died in combat 1 time(s)</font>
<font color="red">[INFO] - Time to shop!</font>
class net.sourceforge.kolmafia.request.GenericRequest
Requesting: https://www.kingdomofloathing.com/place.php?whichplace=edunder&action=edunder_leave
Retrieved: https://www.kingdomofloathing.com/place.php?whichplace=edunder&action=edunder_leave
Field: Location = [choice.php?forceoption=0]
Requesting: https://www.kingdomofloathing.com/choice.php?forceoption=0
Retrieved: https://www.kingdomofloathing.com/choice.php?forceoption=0
Encounter: Like a Bat out of Hell
Finished choice adventure script: auto_choice_adv.ash

Starting choice adventure script: auto_choice_adv.ash
Submitting option 1 for choice 1024
class net.sourceforge.kolmafia.request.GenericRequest
Requesting: https://www.kingdomofloathing.com/choice.php?whichchoice=1024&option=1&pwd
Retrieved: https://www.kingdomofloathing.com/choice.php?whichchoice=1024&option=1&pwd
Field: Location = [fight.php?ireallymeanit=1586118542]
Requesting: https://www.kingdomofloathing.com/fight.php?ireallymeanit=1586118542
Retrieved: https://www.kingdomofloathing.com/fight.php?ireallymeanit=1586118542
Encounter: filthy hippy jewelry maker
Preference _lastCombatStarted changed from 20200405202856 to 20200405202903
Round 0: Player Two loses initiative!
Round 1: You lose 1 hit point
Round 1: You lose 35 hit points
This combat did not cost a turn
Finished choice adventure script: auto_choice_adv.ash

Unsupported choice adventure #1024
<b>choice 1</b>: Return to the fight!
<b>choice 2</b>: Return to your tomb. (1)
<b>choice 3</b>: Not just yet
Interesting.

You went to the Hippy Camp (adventure.php)
It redirects to fight.php
You lost initiative and died immediately.

Redirects to choice 1023
Start choiceadventure script for 1023
choice adventure script handles it and goes to edunder_leave
Redirects to choice 1024
Finish choiceadventure script for 1023
Start chiceadventure script for 1024
submits choice
Redirects to fight.php
You lost initiative and died immediately.
Finish choice adventure script for 1024

And now we are in a choice_follows_fight situation but don't handle it correctly.

Pondering.

It's mostly good so far (finished previous run, started new run) but I just got an abort

Code:
[48] Hippy Camp
Encounter: crusty hippy Vegan chef
Preference _lastCombatStarted changed from 20200408175114 to 20200408175122
Round 0: Player Two loses initiative!
Round 1: You lose 1 hit point
Round 1: You lose 42 hit points
This combat did not cost a turn
Preference _edDefeats changed from 0 to 1
Preference lastEncounter changed from crusty hippy Vegan chef to Like a Bat Into Hell
Encounter: Like a Bat Into Hell
You gain 18 hit points
Submitting option 1 for choice 1023
[INFO] - Ed died in combat 1 time(s)
[INFO] - Time to shop!
[INFO] - Buying Replacement Stomach (30 Ka).
Preference lastEncounter changed from Like a Bat Into Hell to Underworld Body Shop
Encounter: Underworld Body Shop
Encounter: Underworld Body Shop
You learned a new skill: Replacement Stomach
Preference lastEncounter changed from Underworld Body Shop to Like a Bat out of Hell
Encounter: Like a Bat out of Hell
Submitting option 1 for choice 1024
Preference lastEncounter changed from Like a Bat out of Hell to crusty hippy Vegan chef
Encounter: crusty hippy Vegan chef
Preference _lastCombatStarted changed from 20200408175122 to 20200408175132
Round 0: Player Two loses initiative!
Round 1: You lose 1 hit point
Round 1: You lose 42 hit points
This combat did not cost a turn
Preference _edDefeats changed from 1 to 2
Preference lastEncounter changed from crusty hippy Vegan chef to Like a Bat Into Hell
Encounter: Like a Bat Into Hell
You gain 18 hit points
Submitting option 1 for choice 1023
[INFO] - Ed died in combat 2 time(s)
[INFO] - Time to shop!
Preference lastEncounter changed from Like a Bat Into Hell to Like a Bat out of Hell
Encounter: Like a Bat out of Hell
Submitting option 1 for choice 1024
Preference lastEncounter changed from Like a Bat out of Hell to crusty hippy Vegan chef
Encounter: crusty hippy Vegan chef
Preference _lastCombatStarted changed from 20200408175132 to 20200408175139
Round 0: Player Two loses initiative!
Round 1: You lose 1 hit point
Round 1: You lose 43 hit points
This combat did not cost a turn
Preference _edDefeats changed from 2 to 3
Preference lastEncounter changed from crusty hippy Vegan chef to Like a Bat Into Hell
Encounter: Like a Bat Into Hell
You gain 18 hit points
Submitting option 1 for choice 1023
[INFO] - Ed died in combat 3 time(s)
[INFO] - Time to shop!
Preference lastEncounter changed from Like a Bat Into Hell to Like a Bat out of Hell
Encounter: Like a Bat out of Hell
Submitting option 1 for choice 1024
Encounter: Like a Bat out of Hell
Unsupported choice adventure #1024
choice 2: Return to your tomb. (1)
choice 3: Not just yet
Click here to continue in the relay browser.

I'll attempt to get another debug log but it might take a while.

Looking at the log of this run (47 adventures done so far only 9 of which were not combats in the outskirts or hippy camp), it seems to only happen if we repeatedly lose a fight by losing initiative. It's worked fine when it does lose init -> resurrect -> win init, kill and also lose init -> resurrect -> lose init -> resurrect -> win init, kill but this is the first instance of lose init -> resurrect -> lose init -> resurrect -> lose init

Currently I have autoscend only attempting the 2 "free" resurrections and accepting defeat when it would cost Ka to resurrect (so only resurrect when _edDefeats < 3) but someone might want to continue resurrecting as long as they have Ka to spend (e.g. fighting the Level 12 war boss, I often end test runs with 200+ spare Ka).

Code:
> version

KoLmafia v20.3 r19983

Thanks.
 

Veracity

Developer
Staff member
Code:
Encounter: Like a Bat Into Hell
You gain 18 hit points
Submitting option 1 for choice 1023
[INFO] - Ed died in combat 3 time(s)
[INFO] - Time to shop!
Preference lastEncounter changed from Like a Bat Into Hell to Like a Bat out of Hell
Encounter: Like a Bat out of Hell
Submitting option 1 for choice 1024
Encounter: Like a Bat out of Hell
Unsupported choice adventure #1024
choice 2: Return to your tomb. (1)
choice 3: Not just yet
Click here to continue in the relay browser.
Looks like you submitted option 1, but that option was not available, so it sent you back to choice 1024.
(When it said "Unsupported choice adventure", it listed all the options that the choice form had available. No option 1.)
Your choice adventure script exited, but since it was still in the same choice, KoLmafia concluded that your script had not handled the choice and continued with normal automation.
Since there was no whichChoice1024 setting, it aborted.

Did you have no Ka - hence, did not have the option to return to the fight by spending one Ka?
 

Malibu Stacey

Active member
https://www.dropbox.com/s/pp540jo5dujfxre/DEBUG_20200408.txt (forum won't let me upload it, probably due to the size of the file as it's 4.3 MB). Remembered to disable Guide this time so spam should be minimal.

Died to a ratbat (lol).

Code:
Visit to BatHole: The Batrat and Ratbat Burrow in progress...

[134] The Batrat and Ratbat Burrow
Preference lastEncounter changed from batrat to ratbat
Encounter: ratbat
Preference _lastCombatStarted changed from 20200408192036 to 20200408192046
Round 0: Player Two wins initiative!
[INFO] - auto_combatHandler: 0
Preference auto_edCombatCount changed from 97 to 98
Preference auto_edStatus changed from dying to UNDYING!
Preference auto_edCombatRoundCount changed from 133 to 134
Round 1: Player Two casts MILD CURSE!
Round 2: ratbat takes 3 damage.
Round 2: You lose 35 hit points
This combat did not cost a turn
Preference _edDefeats changed from 0 to 1
Preference lastEncounter changed from ratbat to Like a Bat Into Hell
Encounter: Like a Bat Into Hell
You gain 31 hit points
Submitting option 1 for choice 1023
[INFO] - Ed died in combat 1 time(s)
[INFO] - Time to shop!
You acquire an item: mummified beef haunch
[INFO] - Buying a mummified beef haunch!
Preference lastEncounter changed from Like a Bat Into Hell to Like a Bat out of Hell
Encounter: Like a Bat out of Hell
Submitting option 1 for choice 1024
Preference lastEncounter changed from Like a Bat out of Hell to ratbat
Encounter: ratbat
Preference _lastCombatStarted changed from 20200408192046 to 20200408192054
Round 0: Player Two wins initiative!
[INFO] - auto_combatHandler: 0
Preference auto_edStatus changed from UNDYING! to dying
Preference auto_edCombatRoundCount changed from 134 to 135
Round 1: Player Two casts MILD CURSE!
Round 2: ratbat takes 3 damage.
Round 2: You lose 26 hit points
Preference auto_combatHP changed from 20 to 5
Preference auto_edCombatRoundCount changed from 135 to 136
Preference auto_diag_round changed from 0 to 1
Round 2: Player Two casts MILD CURSE!
Round 3: ratbat takes 2 damage.
Round 3: You lose 35 hit points
This combat did not cost a turn
Preference _edDefeats changed from 1 to 2
Preference lastEncounter changed from ratbat to Like a Bat Into Hell
Encounter: Like a Bat Into Hell
You gain 31 hit points
Submitting option 1 for choice 1023
[INFO] - Ed died in combat 2 time(s)
[INFO] - Time to shop!
Preference lastEncounter changed from Like a Bat Into Hell to Like a Bat out of Hell
Encounter: Like a Bat out of Hell
Submitting option 1 for choice 1024
Preference lastEncounter changed from Like a Bat out of Hell to ratbat
Encounter: ratbat
Preference _lastCombatStarted changed from 20200408192054 to 20200408192103
Round 0: Player Two wins initiative!
[INFO] - auto_combatHandler: 0
Preference auto_edCombatRoundCount changed from 136 to 137
Preference auto_diag_round changed from 1 to 0
Round 1: Player Two casts MILD CURSE!
Round 2: ratbat takes 2 damage.
Round 2: You lose 35 hit points
This combat did not cost a turn
Preference _edDefeats changed from 2 to 3
Preference lastEncounter changed from ratbat to Like a Bat Into Hell
Encounter: Like a Bat Into Hell
You gain 31 hit points
Submitting option 1 for choice 1023
[INFO] - Ed died in combat 3 time(s)
[INFO] - Time to shop!
Preference lastEncounter changed from Like a Bat Into Hell to Like a Bat out of Hell
Encounter: Like a Bat out of Hell
Submitting option 1 for choice 1024
Encounter: Like a Bat out of Hell
Unsupported choice adventure #1024
choice 2: Return to your tomb. (1)
choice 3: Not just yet
Click here to continue in the relay browser.


As you can see this time, first death was intentional to get a mummified beef haunch then second and third deaths were because it didn't have enough mana to cast either Storm of the Scarab or Fist of the Mummy because it spent all it's Ka on the mummified beef haunch rather than an MP restore (yes I need to fix that in autoscend). So it doesn't seem to be related to losing initiative repeatedly as I previously thought.
 
Last edited:

Veracity

Developer
Staff member
My guess was correct.

Code:
<td valign=center><input type=button class='button' disable style='color: #cccccc; border: 2px solid #cccccc;' value="Return to the fight! (1 Ka)"></td><td valign=center> <font color=blue><b>Not enough Ka</b></font></td></tr>
The button was disabled with a message saying "Not enough Ka" in blue next to it.
 

Veracity

Developer
Staff member
Note that if you want your script to check the available choice options, you can use

string [int] available_choice_options()

to get a map from option # => button text from the choice form.
 

Malibu Stacey

Active member
Code:
Encounter: Like a Bat Into Hell
You gain 18 hit points
Submitting option 1 for choice 1023
[INFO] - Ed died in combat 3 time(s)
[INFO] - Time to shop!
Preference lastEncounter changed from Like a Bat Into Hell to Like a Bat out of Hell
Encounter: Like a Bat out of Hell
Submitting option 1 for choice 1024
Encounter: Like a Bat out of Hell
Unsupported choice adventure #1024
choice 2: Return to your tomb. (1)
choice 3: Not just yet
Click here to continue in the relay browser.
Looks like you submitted option 1, but that option was not available, so it sent you back to choice 1024.
(When it said "Unsupported choice adventure", it listed all the options that the choice form had available. No option 1.)
Your choice adventure script exited, but since it was still in the same choice, KoLmafia concluded that your script had not handled the choice and continued with normal automation.
Since there was no whichChoice1024 setting, it aborted.

Did you have no Ka - hence, did not have the option to return to the fight by spending one Ka?

OK I think this was my fault. Apologies for wasting your time.

I was handling choice 1024 like so

Code:
		case 1024:  // Like a Bat out of Hell (Actually Ed the Undying)
			if (get_property("_edDefeats").to_int() < get_property("edDefeatAbort").to_int()) {
				// resurrecting is still free.
				run_choice(1, false); // UNDYING!
			} else {
				// resurrecting will cost Ka
				run_choice(2); // Accept the cold embrace of death (Return to the Pyramid)
				auto_log_info("Ed died in combat for reals!");
				set_property("auto_beatenUpCount", get_property("auto_beatenUpCount").to_int() + 1);
			}
			break;

Which looks reasonable but when I first started implementing this, there were a bunch of aborts caused by _edDefeats being incorrectly incremented earlier than it should have been as KoLMafia's handling seems to kill automated adventuring when _edDefeats = edDefeatAbort. I set edDefeatAbort to 4 so I could handle this myself.
I've set edDefeatAbort back to 3 (which is the default) now & will let it run. Any issues should be resolved by tweaking that code I pasted above and/or what I set edDefeatAbort to.
 
Top