Discussing a framework for ascension automation

StDoodle

Minion
As was brought up in my ascend_HC thread, having an overall framework of information to be tracked, and standardized ways of accessing, modifying, and using said information, would be of great value for someone trying to put together a "more optimaler" ascension script.

Now that I'm looking to have a (small amount of) free time again, I'd like to do some further mulling over this concept. Ideally, I'd like to come up with a standardized data file or files that various scripts could access for information on what quests are done, what a player's priorities are (100% runs, which is covered elsewhere & is mentioned as an example of something along these lines that has existing support, specific war medals, etc.), what combat strategies are preferred & when, etc.

The first goal I'd like to work on is WHAT information should be tracked. As for HOW, I'd rather leave that until the "what" has been well-defined.

I'd really like the input of all the major scriptwriters, especially because part of the goal is to have something that can be incorporated reliably into other scripts, such that a player could expect to run various different things for various tasks, without worrying about the scripts overriding their intended play-style.

Yay!
 

fronobulax

Developer
Staff member
For starters I think there are Quests, Conditions and Dependencies. Quests are the game Quests and one can imagine a future version of this awesome script where it is given a Quest - Free the King - and the game is played. A Condition is pretty much anything that can be entered as a KolMafia condition. A Dependency is a linkage between a Quest and a Condition that means the Quest cannot be achieved until all the dependent conditions are accomplished. Playing the game could be nothing more than executing Quests in a fixed order, based upon the Dependencies. I think we need meta-conditions, such as "accumulate 5,000 meat" and sub-goals such as "100% familiar" or "optimize for speed". If the meta-conditions don't accomplish this then there needs to be a way to anticipate or reserve resources - for example, to save meet for a quest item (black paint) instead of spending it on food or booze, or save spleen for healing or save goat cheese for the trapper. These would definitely be shared under the presumption that Eating and Adventuring would be controlled by different components that might also have a standalone function outside of the framework. probably more but this is a conversation, not a thesis.
 

StDoodle

Minion
halfvoid; I'm specifically looking at script libraries & data files for the time being.

Fronobulax; a good start, but it gets complicated when you add in the need to be able to tell a "quest chain" (borrowing from zarqon's post that actually goes pretty far in the direction the wind had blown me toward) what conditions to REEVALUATE under. Ie, some time I want to hit the 8-bit realm until I olfact a blooper, go do other stuff, then come back & finish pixels before OtT runs out. (It's complicated, and I'm really hoping a better speeder than I could break down some of this logic for us to get a feel for some of what needs doing).
 
Last edited:

zarqon

Well-known member
Haha, the lack of 'u' after 'q' throws you off eh?

I'd suggest the following data format:

PHP:
record single_action {
   int ID;       // this action's ID (referenced by prereq)
   int prereq;    // points to an action ID that must be fulfilled before this is attempted (might need to be expanded to contain multiple ID's
   int quant;               // how many to get (if it's an item / choiceadv)
   location where;            // where to adventure
   string req;              // what to get; if none, adventures until check_url contains check_text
   string check_type;        // define the type of check (keywords like haveitem, havefam, completed, functioncall)
                            // if no recognized keyword, it will assume this is a URL to be checked for check_text
   string check_text;       // if this text is found in check_type (familar for havefam, item for haveitem, params for functioncall) will be considered completed
   string chain;     // which quest chain(s) this action is a part of.  Users could specify which chains to include.
};

...in keeping with my previous suggestions. I can't think of anything this wouldn't work for. It's also easily expandable without changing the format, by including new keywords in check_type which would perform different types of checking.

100% familiar runs could be easily handled by making this script sensitive to the relevant ZLib setting. I basically already have this going on since all of my adventuring scripts (and BBB) are sensitive to this setting.
 

slyz

Developer
I would love to see Mafia track which quests are done, this would avoid hitting council.php and/or questlog.php.
From what I gather, only the ones currently tracked are warProgress and the war sidequests.

If Veracity or Jason happen to read this thread: how could we format the data to help with implementation? =)
 

fronobulax

Developer
Staff member
Zarqon's structure looks reasonable except I'm pretty sure prereq will have to be an array and where may also have to be an array as well. Since my Ascend test just burned a lot of turns in the Palidrome without enough meat to buy the items, I am very much aware that having a quantity of meat on hand ought to be a prereq which, in turn, means it would eventually have to have a list of places to adventure to obtain it.

On a practical basis, an Ascension is a list of steps taken in an order deemed to be optimal in some sense. However to be slightly more abstract I keep thinking of something like a PERT chart or perhaps a finite state machine as being a better framework to use to plan and optimize an Ascension.

I also note that optimizations can occur on several levels. If there are multiple prerequisites, what is the optimal order to achieve them? If there are multiple ways to obtain 5,000 meat, what is the optimal way to do so?
 

mredge73

Member
Have you thought about item handling?
Item handling may become very difficult when fully automating a run. Deciding what to equip, buy, sell, create, smash, save, etc. will need to be handled some way.
You may need another format that is designed specifically for item handling or adjust the current one to be more universal to non-adventuring tasks.

Play Style?
We all have our own play style so with a collaboration of script writers our objectives may clash making the script difficult to optimize. You may want to think about a way to police this without upsetting people.
I don't have a copy of Ascension.ash but since it was primarily built by one person then I bet it has a defined play style that mirrors that of its author.

Structure?
Are you proposing that there will be a main script that calls other individual scripts based off of a list of data entries that act as pointers?
I would suggest that each contributing author should only submit one script with everything that they want to add to the project arranged by predefined ID numbers. This will keep this project from swelling to 100 files or more.
This way if the main decides that it wants to run my adventuring routine it can simply issue "call HC_mredge73.ash 208" based off instruction from the datafile.
Or if it decides that based off of some condition that the routine contained in fronobulax's script is prefered it can issue "call HC_fronobulax 209" etc..
This way if we wanted we could all write an adventuring routine to do the same thing but take different paths:
one that does it the fastest way possible, one that does some farming along the way, one that takes the longest way possible, etc..
In this system upon completion of the task the called script will need a way of returning info back to the main or pointing to the next task. This could get tricky.
 
Last edited:

zarqon

Well-known member
Item handling may become very difficult when fully automating a run. Deciding what to equip, buy, sell, create, smash, save, etc. will need to be handled some way.

Yes. I can see three equipment needs: 1) optimizing equipment in a general way as you acquire better items. 2) optimizing equipment for a specific purpose, such as item/meat farming. 3) equipping specific items to enable/unlock specific zones (i.e. putting on the correct outfit for a zone). This is not something we can just call "maximize" on, although that would make a decent temporary solution. Equipment changes seem like something best suited for a betweenBattleScript -- it would use a) goals and b) your current location to determine what to equip between battles:

  1. Equip the proper outfit / accessories for the specified zone and lock those slots.
  2. Try to ensure that you have a valid attack for killing monsters in the zone given your equipment. This would be iffy for spellcasters and should probably be toggle-able.
  3. If you are trying to get items that drop in the zone at a less than 100% rate, it would boost item drop.
  4. If you are trying to get an item that drops specifically from a choiceadv, try to decrease combat frequency.
  5. With remaining slots, maximize +stats / attack stat / meat / regen / whatever.

Unfortunately, there is no way to know in ASH if you have meat or choiceadvs as a goal, so before trying to get meat the script would have to call "maximize meat".

This betweenBattleScript could be expanded to include familiar/buff management as well. It would be friggin' awesome.

Either way, all of the forms of item handling that you mentioned, since they need to be adaptive, must be either a separate function in the script or a separate script entirely (betweenBattle would be best). However, there should be an "outfit" keyword to specify an equipping action since it might be necessary to equip an outfit before performing a non-adventuring action (where the bBB script is not called).

I've actually started work on an EatDrink spinoff that calculates adventures needed to create a given consumable in HC, and if it's efficient it will farm for ingredients as part of the feast-queueing process (before using any consumption helpers). Some of the logic here may be useful for the consumption section of this bytewise ascent script.

Speaking of a name -- I propose a naming contest. The contest for BatMan was great fun!

Play Style?
We all haive our own play style so with a collaboration of script writers our objectives may clash making the script difficult to optimize. You may want to think about a way to police this without upsetting people.

Yes -- but, arguably, if your goal is low turncount there is actually ONE optimal way to play the game at all times -- since it's all just numbers when you break it down. The optimal method will morph as the RNG injects its changes into your play and new content/items/familiars are introduced, but there's still only one way. So far, we've abstracted these numbers a great deal by giving them fantasy-world names like "eat food" and "adventure for an item" -- and we must maintain this not only because ASH does but also because it's useful. We've also mostly not designed algorithms capable of overlapping goals to maximize the numbers. I don't see this script doing that either -- but it looks like the closest thing I've seen yet to bare numbers. We've arrived at a middle ground by breaking the game first into quest chains and then from there into individual little actions. The logic of prioritizing the available actions is where the script will shine because it can calculate drop percentages, etc, between each adventure and change tactics as it goes. My recommended logic for that was described in the thread Doodle linked above.

My short answer: this will be far more optimal than anything yet existing, so playstyle is really a non-factor. Individual chains can be defined for just about everything, and users will be able to include / exclude any chain they choose from consideration. I think that's pretty dang user-friendly.

Structure?
Are you proposing that there will be a main script that calls other individual scripts based off of a list of data entries that act as pointers?

No. I have proposed a three-file arrangement:

1) The data file of actions, which will be pretty dang big and doesn't need to be sorted since every action can have its own ID number, which means it can be handily arranged by chain. Each action (which I'm envisioning as being a very small piece of a quest, such as checking for text on a page, making sure you have X meat, or acquiring a single item) will include enough information that the script will have everything it needs to make the sorting decisions.
2) The script itself, which will interpret the data file, then sort and perform the available actions one by one, with a rebuild/resort after every action.
3) The betweenBattleScript -- which you have led me to believe is necessary -- which maintains moods / items / buffs contingent upon adventuring location / goals, and performs other item management.

Of course, you'll want a good CCS as well, but that's not specific to this script.

I would suggest that each contributing author should only submit one script with everything that they want to add to the project arranged by predefined ID numbers. This will keep this project from swelling to 100 files or more.

Something like this is a good idea. We should arrange the data file similarly to the way KoL defines skills in class-related ranges: all level 1 mandatory actions will be 1XXX (starting at 1000), level 2 mandatory actions will start at 2000 (achieving level 2 would itself be 2000), etc. Non-level-specific mandatory actions (such as unlocking the guild) could start at 20000. The LEW quest could start at 30000, with the 20XXX guild unlocks as prerequisites. The annoying gnomish moxie-sign quest could start at 60000 -- whatever, so long as there's a system for it.
 

fronobulax

Developer
Staff member
but, arguably, if your goal is low turncount there is actually ONE optimal way to play the game at all times
Is that an assertion on your part of have you actually been able to formulate a mathematical model of the game and thus prove that from any game state there is a minimum number of turns required to reach a particular game state and that there is a unique path to do so?

I ask, not to be snarky, but because my sense as a professional mathematician, numerical analyst and operations research specialist is that things are not that easy. I don't know how many times the allegedly optimal heuristic has been shown to be suboptimal. However, viewed from that perspective it is a fascinating problem.
 

zarqon

Well-known member

It's an assertion, meant to be thought-provoking I suppose. My point is just that in the end it's possible to reduce a game like this to a bunch of interrelated numbers -- given that the game has finite limits and is just a huge pile of relationships and sequences. And if that is true, there is such thing as the optimal choice, given a single goal (low turncount). Weighting various goals (meatfarming or efficient leveling) would be an entirely different kind of flying altogether.
 

fronobulax

Developer
Staff member
OK. One key difference is that you seem willing to assert the existence of a unique solution to such a system where my experience has been "It ain't necessarily so". I suspect the simplifications required to analyze KoL might ultimately make the formal analysis less than useful. But I find it an intellectually fascinating problem. Thought provoking is right.
 
Top