Feature ASH location_accessible function.

Veracity

Developer
Staff member
I've continued to put in a lot of work on this project. It's shaping up well, although I have a fair amount of additional work needed, which I will mention as I go along here. I'm about to go away for a couple weeks, so this will be on hold, but here's where we are now and what I'll be working on later.

The goal is for the user to be decide if they are able to automate adventuring in a particular location, given current character state, quest progress, available items, and simple things that KoLmafia could do on your behalf the do not require spending turns or Meat. "Automating" can be done in the GUI, via the "adventure" command in the gCLI (or a CLI script), or via the adventure or adv1 functions of ASH.

KoLmafia attempts to keep its state up to data and in synch with KoL. It's easiest if KoLmafia has been able to see you do everything, but it is a goal to be able to figure out things you did outside of KoLmafia, whether or not they are reported to us by KoL itself. KoL does report quest progress, for example, and we SHOULD be accurate in updating state based on the quest log. Similarly, we know your current inventory (and other "accessible" (configured) sources of items) and your current set of effects, but there are some things you could have done - read a "day pass" for an IOTM you do not own that we can figure out after the fact by taking a look at one of the various area maps.

Here are the three stages of validation.

If you tell KoLmafia to automate - GUI, CLI command, script function - KoLmafia's assumption is that you really want to go there now and it will use not-too-expensive resources that are available to you right now without spending Meat or Adventures. It goes through these three steps in order. Each is allowed to return true or false. False will abort before actually initiating an adventure request.

ASH (Javascript) programs can call the steps manually and make their own decisions on possibly remedies, if any step returns false.

1) boolean pre_validate_adventure(location)

This is intended mostly for zones opened by IOTMs that might be permanently open but also have a (fairly expensive) day pass.
If you have permanent access or have already used a day pass, return true.
Given that you can do things outside of KoLmafia, with neither, peek at a map location to see if you have daily access.
If not, return false. It is up to the user (or program) to decide if a day pass is appropriate.

- Spring Break Beach
- Conspiracy Island
- DinseyLandFIll
- That 70s Volcano
- The Glaciest
- Gingerbread City
- Never Ending Party
- Tunnel of L.O.V.E.
- The Spacegate (not QUITE a day pass; the portable spacegate lets you adventure for 20 turns on a random planet with none of the other amenities of a full Spacegate facility).

To do:

*** FantasyRealm and PirateRealm have day passes. We should look at the Monorail.
*** El Vibrato portal can be seen in your campground. If it is out of energy, leave it to user to decide if - and which kind - of sphere to power it up with.
*** Psychoanalytic couch is visible in Campground. If we don't know which jar, could look at it and see

2) boolean can_adventure(location)

This checks whether zones are currently available, given quest progress, currently available (not too expensive) items, path, any number of things.
Some zones wholly depend on quest progress.
Others can be unlocked by visiting NPCs (the marketplace quests or getting a continuum transfunctioner from the Crackpot Mystic).
Others can be unlocked by using items in inventory (sonars in the Bat Hole, Knob Perfume with a harem girl outfit, Knob Cake with the guard outfit).
Some require particular outfits to be available - and equippable.
Stage 3 will visit NPCs, use items, put on outfits or specific equipment.

Some zones that you have quest-access to have additional requirements we are not willing to make game choices for you to fulfill.
Stench resistance in Guano Junction, Cold resistance on the Shrouded Peak or Icy Peak.

To do - more things that can be validated here, some of which can be done in step 3:

*** Perhaps talk to Lady Spookyraven on 1st and 2nd floor, if haven't done so yet.
*** Talk to trapper to unlock McLargeHuge zones, if at appropriate stage of quest
*** Talk to Melvign to start quest if haven't done so yet
*** The Sea. Whoah, this is complicated. User's call on how to equip, set familiar, get Fishy...

Astral Trips - we already will use a mushroom and select the trip you asked for.
*** Should be a Limit Mode
Shape of Mole
*** Should use a gong and select the form for you.
*** Should be a Limit Mode
Grimstone - we COULD use a mask and select the fairy tale you want to visit.
*** Can we detect if you have finished up with a currently open one?

*** El Vibrato - be willing to use trapezoid - a quest item, which opens the (charged) portal
*** Gingerbread City has daily-limited turns

FantasyRealm requires that you have selected a hat and gotten the G.E.M.
*** given that we will equip the G.E.M., but until you get it, we cannot make the choice for you.
PirateRealm requires that you have acquired the eyepatch and selected ship, crew and equipment.
*** we can equip the eyepatch, but will not select your ship, crew, and equipment

3) boolean prepareForAdventure(location)

- will build a dingy dinghy for any Island zone
- will set you onto a bad, mediocre, or great trip, as requested
*** should use gong and select path of mole
*** should use grimstone, as appropriate
- will acquire and equip Spacegate required gear
- will equip harem girl outfit and use Knob Perfume, if needed
- will equip elite guard outfit and bake Knob cake, if required
- will equip outfit for Dwarven mine office
- will put on Cola War Uniform if requested
- will unequip part of such a uniform if ask to adventure on the battlefield without a uniform. :)
- will get a continuum transfunction from mystic, if needed, and equip it.
- will equip Talisman for the Palindome
- will plant enchanted bean to grow beanstalk, if needed
- will equip swashbuckling getup or pirate fledges for pirate zones
- will use on-hand sonars to blast open Bat Hole rubble
*** Will error and return false with insufficient elemental resistance at certain zones
- will use familiar drops for IOTM zones:
-- Drink Me potion, devilish folio, tiny bottle of absinthe, transporter transponder, Deep Machine snowglobe
-- (Will equip Deep Machine Elf, if you have one.)
- Will equip Drip harness
- Will equip FantasyRealm G.E.M. and unequip familiar
*** Should equip piraterealm eyepatch if needed. Maybe other gear? Not our job to lower your stats...
- Will use appropriate Filthworm stench gland
- Will use item or start quest with NPC for Skeleton Store, Madness Bakery, or Overgrown Lot
(At the moment, will use item if you have it and start quest of you don't. If you want to do the quest, you should start the quest. If you just want to investigate paranormal activity, perhaps you don't care.)
 

Erosion

Member
There appears to have been a change a few days ago that inconsistently causes LT&T to appears as "this zone is unavailable", despite updating the telegram progress prefs when checking with prefref. I suspect the cause is related to changes made regarding location_accessible?
This seems to happen most frequently when trying to telegram after completing a standard ascension that day, but even refreshing all or relogging does not appear to always fix it.
 

Veracity

Developer
Staff member
There appears to have been a change a few days ago that inconsistently causes LT&T to appears as "this zone is unavailable", despite updating the telegram progress prefs when checking with prefref. I suspect the cause is related to changes made regarding location_accessible?
This seems to happen most frequently when trying to telegram after completing a standard ascension that day, but even refreshing all or relogging does not appear to always fix it.
Do you have permanent access or daily access? What do you get when you do:
Code:
get telegraphOfficeAvailable
get _telegraphOfficeToday
What “telegram progress prefs” are you looking at?
 

Erosion

Member
Do you have permanent access or daily access? What do you get when you do:
Code:
get telegraphOfficeAvailable
get _telegraphOfficeToday
What “telegram progress prefs” are you looking at?
Permanent access

> get _telegraphOfficeToday
false both in standard and aftercore even after session refresh, while having a plaintive telegram in my inventory

> get telegraphOfficeAvailable
true both in standard and aftercore

lttQuestDifficulty; lttQuestName; lttQuestStageCount, all three of which updated following manual adventures despite mafia thinking the zone wasn't available at the time.

I haven't had the "LT&T zone unavailable" error happen since that post, it's possible that one of the updates since 26700 resolved the issue.
 

Veracity

Developer
Staff member
telegraphOfficeAvailable means that you installed the IOTM. It doesn't mean it is actually accessible if you are under Standard restrictions.
_telegraphOfficeToday means you don't own the IOTM but have used the "inflatable LT&T telegraph office" today (which you can't do under Standard...)

One or the other has to be true, or you will certainly get "zone is unavailable".

The actual setting that we will (soon - when my current PR goes in) look at is "questLTTQuestByWire". Which is a really weird name, now that I look at it; internally we use Quest.TELEGRAM. The actual adventuring zone - "Investigating a Plaintive Telegram" is only available when you have accepted the quest and received the "plaintive telegram" item.

I suppose it could check for the presence of that item in inventory. I don't know that we actually remove it when you finish the quest. Does it go away when you finish the quest or abandon it? Does it go away at rollover?

In any case, as of my (current) PR:

pre_validate_adventure($location[Investigating a Plaintive Telegram]) will return true if you have permanent or daily access - and if you don't have permanent, it will go look at town_right to see if you have the inflatable booth, if we didn't notice you using it.

can_adventure($location[Investigating a Plaintive Telegram]) will return true iff the quest setting is not "unstarted".
 

Erosion

Member
_telegraphOfficeToday means you don't own the IOTM but have used the "inflatable LT&T telegraph office" today
I see. I didn't think about it too hard and thought it simply meant "did you accept a quest today?" No problem.
I don't know that we actually remove it when you finish the quest. Does it go away when you finish the quest or abandon it? Does it go away at rollover?
It removes itself from inventory when the quest is completed or abandoned, and does persist across rollovers until completed/abandoned/ascension.
 

Alium

Member
Code:
ash can_adventure($location[Degrassi Knoll Restroom])

This is returning true for me. I don't have immediate access to it as I have not unlocked my guild to start the meat car quest. In this run I did start out in vole (Degrassi available) and then tuned to wombat (desert).

Is returning true here intended? Learning how to use these commands.
 

Veracity

Developer
Staff member
I was not aware that non-Knoll signs required the meatcar guild task in order to unlock the hostile Knoll. Actually, I am not sure when the non-hostile Knoll becomes available. May be the same trigger.

I’ll look into it. Thanks for the report!
 

Alium

Member
Ah I'm not very familiar with unlocking the hostile knoll either. Wiki says beginning the untinker quest unlocks it. Which is preferable to guild quest as no adv's are required in my case. Did confirm that starting the untinker quest as a non-Knoll sign unlocked the hostile Knoll.

So perhaps this isn't an issue with can_adventure and instead something that can be added to prepareForAdventure? Either way, thanks for looking into this!
 
I'm getting an error where mafia is errantly reporting that I can adventure in The Haunted Bedroom in CS aftercore when I'm unable to.

It looks like the code in question is here:
Code:
(KoLCharacter.getLevel() >= neededLevel
                  && (InventoryManager.hasItem(SPOOKYRAVEN_NECKLACE)
                      || InventoryManager.hasItem(GHOST_NECKLACE)))

I'm level 17, and have the ghost of a necklace. But the ghost of a necklace isn't a quest item, and accumulates in my inventory ascension after ascension.

I'd throw in a quick PR for this, but I'm also not 100% sure what the logic there is meant to represent. Checking for the spookyraven necklace seems to represent the failure state for "the quest isn't complete but you are able to complete it right now"--if that's the case, could we just snip out the ghost necklace from that logic? Or should we replace that with a check for having completed the previous quest, rather than having started the current one?
 

Veracity

Developer
Staff member
You complete Lady Spookyraven's 1st quest by getting the necklace and giving it to Lady Spookyraven.
She then drifts upstairs and you get the ghost necklace.
You start Lady Spookyraven's 2nd quest by talking to her on the second floor after she sends you KMail asking you to talk to her on the second floor.

You are apparently doing two things that I have absolutely no interest in ever doing myself: casual ascensions and the community service path. I assume it is the former which lets the ghost of a necklace "accumulate" in your inventory. Unless you empty storage every time you free the king - which also something I never do. :)

I think the ghost necklace is intended to stand in for "have we completed the necklace quest".

I'll revisit this, by and by. I'm currently working on the Ocean and El Vibrato stuff.
 

gausie

D̰͕̝͚̤̥̙̐̇̑͗̒e͍͔͎͈͔ͥ̉̔̅́̈l̠̪̜͓̲ͧ̍̈́͛v̻̾ͤe͗̃ͥ̐̊ͬp̔͒ͪ
Staff member

Veracity

Developer
Staff member
Ah I'm not very familiar with unlocking the hostile knoll either. Wiki says beginning the untinker quest unlocks it. Which is preferable to guild quest as no adv's are required in my case. Did confirm that starting the untinker quest as a non-Knoll sign unlocked the hostile Knoll.

So perhaps this isn't an issue with can_adventure and instead something that can be added to prepareForAdventure? Either way, thanks for looking into this!
I ascended into a hostile Knoll sign.
I saved DEBUG logs visiting the Untinker and accepting his quest.
I notice that "questM01Untinker" remains "unstarted".
I notice that he didn't say "I'll mark it on your map for you" - but the Knoll is on my map anyway.

I see a number of bugs in the code to handle this quest. Since I have DEBUG logs, they will be easy to fix.
Once I do that, I will certainly make "talking to the untinker and accepting his quest" part of prepareForAdventure, if you have not accepted it through the guild.
 

Irrat

Member
Haunted bedroom is still incorrect, reported that I could adventure there immediately after I received the necklace from writing desk.

Obviously, I couldn't. I still needed to deliver my necklace, then talk to them on the second floor.

js canAdventure(Location.get("The Haunted Bedroom"))

Perhaps its worth checking if questM21Dance has been started?
 

Veracity

Developer
Staff member
canAdventure is correct; you can adventure there. You just need to do a couple things first - talk to Lady Spookyraven on the first floor followed by talking to her on the second floor. Neither of those actions consume resources; they are simple requests that use no turns.

The prepareForAdventure function will do them.

That is the contract of canAdventure/prepareForAdventure: the first says that a location is accessible with, perhaps, some easy cost-free fixes which the second will do.

KoLmafia adventure automation - GUI, CLI command, ASH/JS functions - call preValidateAdventure/canAdventure/prepareForAdventure in sequence. If you want to submit adventure URLs via visitUrl, say, you should do the same.
 
Top