Results 1 to 5 of 5

Thread: 19537: Law of Averages is reusable. Add ability to specify extra fields when automati

  1. #1
    Feed Reader RSS Bot's Avatar
    Join Date
    Jul 2009
    Posts
    12,067

    RSS 19537: Law of Averages is reusable. Add ability to specify extra fields when automati

    Law of Averages is reusable. Add ability to specify extra fields when automating choices:
    set choiceAdventure1391=1&tossid=10320
    ash run_choice ( 1, "tossid=10320" );

    by veracity0 on 2019-09-10 22:05:53

    M /src/data/items.txt (view) (diff)
    M /src/net/sourceforge/kolmafia/session/ChoiceManager.java (view) (diff)
    M /src/net/sourceforge/kolmafia/textui/RuntimeLibrary.java (view) (diff)
    Download the latest KolMafia build here.
    Every new revision posted within the hour.
    New EXE builds every Monday.

  2. #2
    Senior Member Crowther's Avatar
    Join Date
    Nov 2006
    Posts
    1,489

    Default

    I'd file this under, "Don't do that", but if you don't have the item in question, there will be an infinite loop of debugging logs.

  3. #3
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    12,180

    Default

    Yeah. For now, I'm assuming that if you are automating this, you will pre-stock with enough supplies, given hippy/frat boys remaining, how many turns you are spending, how many you defeat on normal fights, etc. Or, if you are scripting and using run_choice(), you will acquire (at least) enough before you get there - and will restock, if needed, before continuing to the next one.

    If you specify an option that is not currently available for any choice, we go to manual decision:

    Code:
    			// Make sure that KoL currently allows the chosen choice
    
    			if ( !ChoiceUtilities.optionAvailable( decision, request.responseText ) )
    			{
    				KoLmafia.updateDisplay( MafiaState.ABORT, "Requested choice (" + decision + ") for choice #" + choice + " is not currently available." );
    				ChoiceCommand.printChoices();
    				request.showInBrowser( true );
    				return;
    			}
    We actually do have a mechanism for doing extra validation on choices -

    Code:
    	private static final String specialChoiceDecision1( final int choice, String decision, final int stepCount, final String responseText )
    Notice that it has the responseText, so we can look. Here is what we do for the Tomb of the Unknown <Your Class Here>

    Code:
    		case 1049:
    		{
    			// Tomb of the Unknown Your Class Here
    
    			// This handles every choice in the "The Unknown Tomb"
    			// Many of them have a single option.
    			TreeMap<Integer,String> choices = ChoiceUtilities.parseChoices( responseText );
    			if ( choices.size() == 1 )
    			{
    				return "1";
    			}
    
    			// The only one that has more than one option is the initial riddle.
    			// The option numbers are randomized each time, although the correct
    			// answer remains the same.
    			String myClass = KoLCharacter.getClassType();
    			String answer =
    				myClass == KoLCharacter.SEAL_CLUBBER ? "Boredom." :
    				myClass == KoLCharacter.TURTLE_TAMER ? "Friendship." :
    				myClass == KoLCharacter.PASTAMANCER ? "Binding pasta thralls." :
    				myClass == KoLCharacter.SAUCEROR ? "Power." :
    				myClass == KoLCharacter.DISCO_BANDIT ? "Me. Duh." :
    				myClass == KoLCharacter.ACCORDION_THIEF ? "Music." :
    				null;
    
    			// Only standard classes can join the guild, so we
    			// should not fail. But, if we do, cope.
    			if ( answer == null )
    			{
    				return "0";
    			}
    
    			// Iterate over the option strings and find the one
    			// that matches the correct answer.
    			for ( Map.Entry<Integer,String> entry : choices.entrySet() )
    			{
    				if ( entry.getValue().contains( answer ) )
    				{
    					return String.valueOf( entry.getKey() );
    				}
    			}
    
    			// Again, we should not fail, but cope.
    			return "0";
    		}
    I could add an extra argument to that - the extra fields you specify - and add code to handle choice 1391 in particular. Of course the "extra fields" functionality is generic, so it is always "don't do that" for anything we don't have that kind of error checking built in.

    If I code up something for this, I wouldn't be able to test until tomorrow, and I am planning to spin a (final?) point release today. I'll be back on the battlefield tomorrow for my 13th run. I suppose I can put off the point release until then.

  4. #4
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    12,180

    Default

    Hah. Well, I have the technology to do this:

    Code:
    > test load selects.txt
    
    Read 2,659 bytes into a 2,659 character string
    
    > test visit-choice
    
    choice = 1391
    choice 1: Toss!
    choice 2: Never Mind
    
    select = tossid (24 options)
        0 (--- select an item ---)
        161 (ghuol egg (2) (5 casualties))
        330 (glass of goat's milk (5 casualties))
        471 (hot wing (6) (5 casualties))
        669 (ghuol guolash (18 casualties))
        672 (cranberries (3) (5 casualties))
        1769 (fricasseed brains (5 casualties))
        1776 (stale baguette (5 casualties))
        1778 (ancient frozen dinner (6 casualties))
        1952 (desiccated apricot (5 casualties))
        1954 (dehydrated caviar (5 casualties))
        2063 (blackberry (2) (5 casualties))
        2843 (dire fudgesicle (2) (5 casualties))
        3555 (sea carrot (5 casualties))
        6416 (mana curds (10 casualties))
        6422 (vampire chowder (10 casualties))
        6705 (jungle floor wax (6 casualties))
        7368 (extra-flat panini (2) (8 casualties))
        7375 (actual tapas (5 casualties))
        8412 (succulent marrow (3) (6 casualties))
        8413 (salacious crumbs (5) (6 casualties))
        8526 (pink slime (2) (5 casualties))
        9953 (PB&J with the crusts cut off (4) (5 casualties))
        10179 (plain snowcone (12) (5 casualties))
    Might be useful to make the "choice" command show you that stuff, too.
    Needs more work, since a "select" input only applies to one of the forms - "choice 1", in this case.

  5. #5
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    12,180

    Default

    Right.

    Code:
    > test load selects.txt
    
    Read 2,659 bytes into a 2,659 character string
    
    > test visit-choice
    
    choice = 1391
    choice 1: Toss!
      select = tossid (24 options)
        0 (--- select an item ---)
        161 (ghuol egg (2) (5 casualties))
        330 (glass of goat's milk (5 casualties))
        471 (hot wing (6) (5 casualties))
        669 (ghuol guolash (18 casualties))
        672 (cranberries (3) (5 casualties))
        1769 (fricasseed brains (5 casualties))
        1776 (stale baguette (5 casualties))
        1778 (ancient frozen dinner (6 casualties))
        1952 (desiccated apricot (5 casualties))
        1954 (dehydrated caviar (5 casualties))
        2063 (blackberry (2) (5 casualties))
        2843 (dire fudgesicle (2) (5 casualties))
        3555 (sea carrot (5 casualties))
        6416 (mana curds (10 casualties))
        6422 (vampire chowder (10 casualties))
        6705 (jungle floor wax (6 casualties))
        7368 (extra-flat panini (2) (8 casualties))
        7375 (actual tapas (5 casualties))
        8412 (succulent marrow (3) (6 casualties))
        8413 (salacious crumbs (5) (6 casualties))
        8526 (pink slime (2) (5 casualties))
        9953 (PB&J with the crusts cut off (4) (5 casualties))
        10179 (plain snowcone (12) (5 casualties))
    choice 2: Never Mind

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •