holatuwol begins scripting

Status
Not open for further replies.

holatuwol

Developer
Okay, so far, most of KoLmafia's scripting engine has been developed just by taking user feedback and cool ideas and integrating them together. Neither Veracity nor myself really write any KoLmafia scripts, so the perspective we have, while broad in nature, is also rather limited to what we're interested in doing.

This is about to change. I've started writing a few CLI scripts and I'm beginning to tread into ASH scripting territory, and along the way, I've added small features here and there in order to get the scripting engine to work as I expect it should as I'm writing a script. Why? Because it didn't behave as I thought it did. As I write more scripts, I expect the number of changes to increase and for the scripting engine to get better..

Here's where you come in. Your mission is to come up with a scripting concept. The idea is to make the script sound as simple as possible, but where you've experienced a road block (and you shouldn't tell me about it). Now, after reading through the proposal, if it sounds simple enough, I'll try to write a script for it and post the result, likely running into the same road block, possibly modifying KoLmafia's underlying ASH interpreter engine in order to do so.

Now, if I don't run into the road block (I find a way around it) you'll get to see the workaround, and maybe learn something about the ASH that you didn't know before. :) That's the idea. Post your suggestions, and we'll see what I'm really capable of doing. ;)
 

Veracity

Developer
Staff member
Heh.

Well, holatuwol is right: I've put hundreds of hours of development into ASH, not because I actually USE it, but because I have literally years of professional experience working on programming language development environments (Lisp) and CLIs (for internet routers) and it was a fun little project for me.

I STILL don't feel the need to script anything; I don't actually run either of my two multis except when I want to test something for KoLmafia and need a character with available turns and/or meat, and I'm perfectly happy with KoLmafia's GUI and the Relay Browser for my hardcore-ascending main character.

So, I look forward with interest to seeing what people who actually USE this programming language I've worked so hard on still miss in it.

Go for it. :D
 

Metraxis

Member
Alright, I'll bite. Here's the scenario.

You are at the Castle in the clouds in the Sky, and (because you are playing Hardcore, or forgot to stock up) you need to get all five items yourself rather than pulling them from Hagnk's. You have positive MP regeneration from some source (pith helmet, purple snowcone, statis, whatever), so there are excess MP to burn. Finally, you have a fast and very effective airship strategy already, so you can't count on having soft green echo eyedrop antidotes in stock. The script has three Parts:

Part the first:
During this part, your goal is to accumulate four of the five items you need from the various giants (heavy D, awful poetry journal, furry fur, giant needle). To save turns, you choose to boost Combat % with Musk of the Moose. You may have Smooth Movement left over from the Airship, and this needs to be permitted to expire.

Part the second:
Now that you have the drop-only items, you still need a thin black candle and a couple spins on the wheel, so it's time to let Musk of the Moose expire, and bring on the Smooth Movements. As before, the unwanted self-buff needs to be permitted to time out, ideally in less than 12 turns.

Part the third:
Now you have a candle, and its time to make a rowboat. But will a use of the map be successful? You want to be nice to the servers, but you want to save every turn you can, so you want to use the map as soon as it will work, but no earlier.
 

holatuwol

Developer
This script takes advantage of three not-well-known aspects of KoLmafia's scripting engine. The first is the idea of placing ASH functions in the CLI namespace. The second, the use of the "betweenBattleScript" feature. The third is the use of "trigger" CLI commands to adjust the player's mood to have KoLmafia auto-maintain buffs rather than writing custom handlers to do so.
 

Attachments

  • castle.ash
    6 KB · Views: 119

holatuwol

Developer
In general, for this project, it's required to allow for ASH+CLI solutions, since the CLI isn't designed to handle conditionals and such to the same level; modularization is also messy. However, to answer your question:

if bitchin' meatcar == 0
create 1 bitchin' meatcar
 
OK I got 2 of them.

Scenario: your preference is to buy the components for the 1337 scroll from the mall, make the 1337 scroll, and convert it to worthless items and trade them to the hermit, but you may be in a position where you cannot do this so hit the sewer. If you cannot use a 1337 scroll don't buy the components, or try to use it.

Second scenario: you want to do a daily stash log report sorted by playername instead of time and output it to a file in order to seek out people in need of promotions, and people in need of booting.
 

Metraxis

Member
Very nice, holatuwol.  I learned some interesting things from reading that.  I do have a question though.  In the version of KolMafia I'm using, which is an older daily build, conditional recast will recast any buff or self-buff you have active, regardless of whether it is in your mood or not.  Is this a bug, then?


Edit: Uh, I hit edit instead of reply, so I'm re-adding the original post.  There were no actual modifications (yes, I hit the wrong buttons sometimes!). Except for the name typo ... but I edit that a lot anyway. ;D
 

holatuwol

Developer
Your preference is to buy the components for the 1337 scroll from the mall, make the 1337 scroll, and convert it to worthless items and trade them to the hermit, but you may be in a position where you cannot do this so hit the sewer. If you cannot use a 1337 scroll don't buy the components, or try to use it.

Edit: I'm seeing some really awkward situations given the vagueness of this description, pending on how I interpret "unable".  So, let's scratch my previous response and ask for clarification.  In the event that you've never used a 31337 scroll before (thus have no backdoor access), should the script (a) use 31337 scrolls until it's hacked the hermit, or (b) should it pretend that you want to go sewer fishing?


Second scenario: you want to do a daily stash log report sorted by playername instead of time and output it to a file in order to seek out people in need of promotions, and people in need of booting.

As for this one, the clan stashlog command does exactly what you're describing (and even color-codes the transfers), so I'm rather confused by it?

I do have a question though.  In the version of KoLmafia I'm using, which is an older daily build, conditional recast will recast any buff or self-buff you have active, regardless of whether it is in your mood or not.  Is this a bug, then?

No, that's not a bug, as that's exactly how I use conditional recast -- I use it when I don't feel like setting up a mood right then but I want to just burn MP as I'm adventuring.  In the script, I deactivate conditional recast -- mpThreshold is the KoLmafia property that corresponds to it, and giving it a negative value (or even zero value) causes KoLmafia to skip over it.

Edit: Ah, I see now, I misinterpreted the "excess MP to burn".  I thought that meant, "It's okay to add more buffs than just the non-combat ones," not, "I might hit max MP in 10 turns, and I don't want any of that MP to go to waste."  Hah.  Well, that means the built-in functionality isn't quite good enough for what you'd like to have happen.  I'll think about this.

Edit 2: So, after writing an over-zealous custom mood maintainer given the constraints, I decided that I'd just render the over-zealous custom mood maintainer obsolete and add a preference, which will be present in the next release.
 

Attachments

  • castle.ash
    9.3 KB · Views: 70

Metraxis

Member
burn_castle_mp() is a nice piece of work, though I'll admit a "Limit conditional recast to current mood" checkbox would probably be easier to use for people who haven't already implemented complex buff-handlers for their scripts. :)
 

holatuwol

Developer
After writing that script, I thought about banning minimalistic scripts and edited my post a few times to suggest a ban, but you know, I think that's where most of the road blocks are right now. So a ban would be counter-productive. I will, however, consider adding a fine for making minimalistic scripting concept suggestions. Like, you have to send me a dozen hyperbolic plasma focusers every time you try it or something. ^_~
 
[quote author=holatuwol link=topic=752.msg3614#msg3614 date=1170874501]


Edit: I'm seeing some really awkward situations given the vagueness of this description, pending on how I interpret "unable". So, let's scratch my previous response and ask for clarification. In the event that you've never used a 31337 scroll before (thus have no backdoor access), should the script (a) use 31337 scrolls until it's hacked the hermit, or (b) should it pretend that you want to go sewer fishing?
[/quote]

What I am trying for is a script that will use 1337 scrolls for worthless items if it can use them. The way that I am checking whether or not they can is
Code:
if(contains_text(visit_url("mountains.php"), "valley2.gif"))
but if they have the bridge or the abridged dictionary I want to go ahead and bridge the chasm so that the if statement will return true. Anyway, I just figured it out after a week, so that request can be disregarded.

[quote author=holatuwol link=topic=752.msg3614#msg3614 date=1170874501]
As for this one, the clan stashlog command does exactly what you're describing (and even color-codes the transfers), so I'm rather confused by it?
[/quote]

Didn't know that function existed. Maybe I should read the manual again another time since I've read it maybe 50 times and missed that.
OK Maybe convert this to a bug report?
I see what the name of the function implies, but what I am actually getting is only the comings and goings of the clan, and nothing about the stash activity. See the attached files.
 

Attachments

  • stashlog.htm
    2 KB · Views: 59

holatuwol

Developer
Metraxis said:
Forgive the density, but what do you mean by 'minimalistic'?

Scripts that attempt to avoid "waste".


efilnikufecin said:
What I am trying for is a script that will use 1337 scrolls for worthless items if it can use them.

Odd, I thought the only flag on the 31337 scroll was level (ie: you have to be level 9).  You mean you have to actually bridge the chasm?


efilnikufecin said:
I see what the name of the function implies, but what I am actually getting is only the comings and goings of the clan, and nothing about the stash activity. See the attached files.

Meh.
 

Metraxis

Member
Scripts that attempt to avoid "waste".

Ouch. Sadly, before they give you a degree in Mathematics, you have to prove you're an irredeemable Platonist, so all my scripting is about avoiding waste (initially, avoiding the waste of up to 20 turns in degrassi knoll because I forgot to visit the untinker before trying to find his screwdriver)

Also, is it a bad sign when your scripts start nagging you to pick up an AT buff?



Edit: I need to lose the ability to edit other posts. This is getting rather embarrassing. -- holatuwol
 

holatuwol

Developer
[quote author=holatuwol link=topic=752.msg3624#msg3624 date=1170886907]Sadly, before they give you a degree in Mathematics, you have to prove you're an irredeemable Platonist, so all my scripting is about avoiding waste (initially, avoiding the waste of up to 20 turns in degrassi knoll because I forgot to visit the untinker before trying to find his screwdriver) :)

Also, is it a bad sign when your scripts start nagging you to pick up an AT buff?[/quote]

Haha, no, there are all sorts of warning messages I've added to scripts, just to help me track where I am.  As for the "ban," I just meant a ban on scripting concepts to ask me to write.  I tend to write very inefficient scripts in the general case, because I figure if I can't be bothered to be efficient, I shouldn't ask a script to do so.  So, asking me to write an efficient script is like prying teeth, and I'd prefer not to.

But, I recognize that's where the hiccups are right now, so as long as it's really something you've been poking at and haven't found an elegant solution to, and from the description it sounds like it should be simple (and I, at some level, agree), then it's fine as a request.
 
When an equipment item drops, I would like to see if it's better suited for my current needs than what I currently have on, and if so equip it, and continue adventuring. At one time I thought about requesting the ability to tell kolmafia to call a script when combat ends (and an item drops) with the item that dropped as a parameter. I shot my own idea down when I realized that someone would write a script for that feature which put the item in their closet or store or something and hammer the servers needlessly. Any ideas for this?
 

Metraxis

Member
It would. If you look around the forums a bit, you should find an early version of my Lib.Equipment and Dress.ash scripts. If you're a softcore player, then you'll likely need to add a bunch of stuff to Lib.Equipment to make use of the things you pull, but it should suffice for most Hardcore people, though if it chokes, it will tell you what you are wearing that it doesn't recognize. Once the Equipment map is actually complete, I'll be posting it again.
 
Heh I keep forgetting about between battle scripts since they were moved to the moods section of kolmafia. Though there have been a lot of bumps in the road along the way, I think the advanced scripting handler is doing really well. Most of the previous issues have been fixed, or can easily be worked around. Congrats on that Holatuwol, and Veracity. Also I would like to say again Thanks for your efforts.
 
While writing a script which changes some kolmafia properties, then changes them back when done I thought of something. I want to be absolutely certain that the properties get set back to what they were before the script started no matter what happens. I want to be able to give the script to other users to use so it isn't feasible to write a separate script to restore the properties because some of them know nothing about scripting, and have their properties set up differently than needed in the script (and want them back the way they had them when done or stopped). I fully realize that if they use windows task manager to end kolmafia, it's out of our hands and the properties will have to be manually restored.
 
Status
Not open for further replies.
Top