Features I wish ASH supported...

Arrays.
Global variables.
Circular function calls.
For loops.
Case or Switch statements.

Anyone else have gripes that I missed? I end up writing most of my scripts in Java, actually, because ASH just can't do many of the things I expect from a scripting language. And I like java, but that's beside the point... I would use ash more if I could, because I can actually share my ash scripts with people but I can't effectively share my random patches to the KoLmafia source code. I'm just wondering if others are in the same boat.
 
You certainly aren't alone.

But as the saying goes, "beggers can't be choosers."

But.... Perhaps we could start a Java forum here. One were those of you (us) that can mess with mafia's code can share your patches? As long as there are a couple of stickies pointing out the most viable Java programs (editors, compilers and such) with tutorials, or at least links to tutorials, I'd be all for it.

But two voices do not a majority make - unless there are only three members here. And I know there are more than three.
 
A java section of the forum might indeed be a useful resource; however there is one concern that I'm not sure how to resolve.

Holatuwol has expressed legitimate concerns from time to time about people (ignorant, or downright stupid people) abusing KoLmafia to do things that are harmful to the game; things like making aggressive mall-hunting bots, kmail-spamming scripts, clan-stash-looting scripts, etc. Many of the higher-level features I wish for are missing specifically because he worries that providing them would make things too easy for the bad folks.

So most of my java changes have been to provide this kind of feature, for my own (hopefully responsible) use. For example, I've implemented the following ASH command:

buyat(int maxPrice, int howMany, item theItem) - buys only if price is lower than maxPrice. Used by me to protect myself from random extreme price spikes; I was inspired by a situation a few weeks ago when squashed frogs jumped from ~100 meat to ~30,0000 meat due to some random asshats trying to manipulate the market... the same could easily occur with some item I might actually be wanting to purchase. But the same command could be used by someone else in a tight loop to prowl the mall for mispriced items, imposing lots of server load and making the game less fun for other players.

I really wouldn't want to start posting patches of this sort publicly, or encouraging others to do so, for fear that it would discourage holatuwol from continuing to develop this program that we all love so much. Also, I don't want to give the asshats any more tools than they already have. ;-)

On the other hand, I also have a patch that farms the tavern celler (before turning off the faucet) for an arbitrary number of turns to collect rat appendices (and whiskers) or free booze. I have seen at least two requests for exactly that function on the KoLmafia thread in the kol forums, and it doesn't seem prone to abuse. So that's something I would love to share.

I would just want to make sure that if we do start a java code posting forum, we do so in a way that makes holatuwol comfortable with the process.
 

macman104

Member
[quote author=Bucket de Mowbray link=topic=35.msg85#msg85 date=1143755552]buyat(int maxPrice, int howMany, item theItem) - buys only if price is lower than maxPrice. Used by me to protect myself from random extreme price spikes; I was inspired by a situation a few weeks ago when squashed frogs jumped from ~100 meat to ~30,0000 meat due to some random asshats trying to manipulate the market... the same could easily occur with some item I might actually be wanting to purchase. But the same command could be used by someone else in a tight loop to prowl the mall for mispriced items, imposing lots of server load and making the game less fun for other players.[/quote]Yes, I would say that keeping this kind of information either to yourself or in responsible hands would be the best decision, because this is basically mallbot capability, and it would be more than unfortunate if holatuwol became uncomfortable with the information being circulated enough to stop working on the project.
 
I guess I'll join ya on this one. Of course I want arrays, and global variables. Another ability I would love to have is to be able to obtain an items item number in the KOL database.

It would be something like "string item_to_string( [item])" except it would be "int item_to_int( [item])" an acceptable substitute would be "string item_to_item_number( [item])" which would return the string representation of the item number. Actually skipping int would reduce scripting code even more because I wouldn't have to convert the int to a string.

A script could be written to accomplish this, but it would be one really long script! I do believe all this information is already stored in kolmafia's database though, and if so shouldn't take much code at all to implement.
 
Quick one liners:

Ability to check total fullness and/or spleeness. (Not going to happen.)

A way to record values between scripts. Either variable values, or writing and reading to a file.
 

Nightmist

Member
[quote author=Presto Ragu link=topic=35.msg174#msg174 date=1144294715]
Ability to check total fullness and/or spleeness. (Not going to happen.)[/quote]

That applies to pretty much everything you cant do ingame.

[quote author=efilnikufecin link=topic=35.msg170#msg170 date=1144259363]
A script could be written to accomplish this, but it would be one really long script![/quote]
Hmm your request is my new mission, kind of... Check the scripts page for it.

Edit: As in the work in progress one since its always going to be out of date as items are introduced into the game.
 

Tirian

Member
Turning the scripting language into C or Java is more than I want to ask for. I think it's powerful enough to do whatever we could want to do. But I would like to see more library functions to give us wider knowledge of the Kingdom.

Here's my first stab at a list of CLI/ASH functions I'd love to see, undoubtedly sorted so that Holatuwol's blood pressure would rise throughout. :D


  • [li] I'd like to know if I'm in hardcore
    [/li][li] I'd like to know if a location is available for adventuring without adventuring there
    [/li][li] I'd like to know how many storage pulls I have left today
    [/li][li] I'd like to know if today is a clover day
    [/li][li] I'd like to know my progress level in a given quest. Is the Boss Bat dead? What ore does the Trapper need?
    [/li][li] I'd like to know how much fullness and spleeness I have taken up in this session
    [/li][li] I'd like to be able to do the final room of the NS lair one step at a time (so, for instance, I can face my shadow with a linoleum sword instead of a mirror shard)
    [/li][li] I'd like a function like tavern() that clears the mine as cleverly as can be expected
    [/li][li] I'd like to be able to set a parameter that says that I want to cast Saucy Salve instead of attacking when my health falls below a certain level- I'd like to be able to adapt the custom combat parameters from scripts and to write ASH-based adventures that use the CCS.[/li]
 

Tirian

Member
Yeah. the fifth item is more specifically attuned towards knowing if it's a good idea if running a quest would be a good idea. I mean, you can tell if you need to get the abridged dictionary just by checking to see if you can adventure in the Valley, but there's no clear way to know if you should fight Felonia without actually reading the Quest Log to see if you've already defeated her.

Knowing about where you can adventure has more generic goodness too. If you want to write a script that puts a level 6 character into good adventuring situations, maybe they should be at the Friar's gate or maybe in the Knob Goblin lab or somewhere in the Menagerie or maybe even the Pirate's cove. It depends on your gear and class and the amount of stat buffage that you can acquire. You can script checking your stats against all these zones, and I'm going to go down that road soon I guess, but it would be so universally beneficial that it would be nicer to stick it in the language instead of a user library.
 

Veracity

Developer
Staff member
[quote author=Bucket de Mowbray link=topic=35.msg71#msg71 date=1143717964]
Arrays.[/quote]

Revision 574 (KoLmafia 7.8 ) provides Maps, which allow you to do everything you could with an array and more.

Global variables.

Revision 435 (KoLmafia 7.7) provides this.

Circular function calls.

If by "circular" you mean "recursive", that is allowed, as of revision 598 (KoLmafia 7.9).

If by "circular" you mean "mutually recursive", that requires forward references for functions, which is allowed, as of revision 607 (KoLmafia 7.9).

For loops.

Revision 582 (KoLmafia 7.9) provides:

Code:
int [int, int] map2;
foreach key1 in map2
    foreach key2 in map2[key1]
        print( "map2[" + key1 + "," + key2 + "] = " + map2[key1,key2] );

Revision 599 (KoLmafia 7.9) provides:

Code:
for x from 10 upto 20 by 2
   for y from 20 downto 16
        print( "x = " + x + " y = " + y );

Both kinds of loop allow "break" and "continue".

Case or Switch statements.

This is not going to happen. Since they are basically syntactic sugar for an if/else if/else chain, lack of such a construct doesn't prevent you from coding the control flow of your choice.

Anyone else have gripes that I missed?

Suggestion: change your attitude - or at least how you express it in the presence of the KoLmafia developers - such that the word "gripe" is not part of it.

[quote author=Presto Ragu link=topic=35.msg174#msg174 date=1144294715]
Ability to check total fullness and/or spleeness.  (Not going to happen.)[/quote]

Right. KoL doesn't display it for us, therefore, there is no way that KoLmafia can know where you are in today's consumption. But see later...

A way to record values between scripts.  Either variable values, or writing and reading to a file.

Revision 573 (KoLmafia 7.8 ) provides get_property() and set_property().
Revision 590 (KoLmafia 7.9) provides a complete set of string_to_xxx() functions, corresponding to the previously existing xxx_to_string() functions, so you can use any convenient data type as a property.

[quote author=Tirian link=topic=35.msg600#msg600 date=1146543257]
Turning the scripting language into C or Java is more than I want to ask for.  I think it's powerful enough to do whatever we could want to do.[/quote]

Well, especially now that I've done the above set of syntax enhancements...

But I would like to see more library functions to give us wider knowledge of the Kingdom.

This is probably what you can realistically expect to see, going forward. :)

I'd like to know if I'm in hardcore
I'd like to know how many storage pulls I have left today
I'd like to know if today is a clover day

These are all the kind of things KoLmafia already knows and displays elsewhere, and thus would be easy enough to turn into little inquiry functions.

I'd like to know if a location is available for adventuring without adventuring there

A bigger project

I'd like to know my progress level in a given quest.
Is the Boss Bat dead?
What ore does the Trapper need?

None of this info is currently available.

I'd like to know how much fullness and spleeness I have taken up in this session

Not likely to happen, because KoLmafia knows nothing whatever about how much fullness, spleeniness, or drunkenness any given consumable causes. Now, I fully expect the busy people on this forum to code up this data, using the new constructs ASH provides - global variables and maps, in particular.

For example

food.ash:

Code:
int [item, int] food_data;

int food_fullness_index = 0;
int food_min_adventure_index = 1;
int food_max_adventure_index = 2;
...

food_data[ $item[Hell Ramen], food_fullness_index ] = 6;
food_data[ $item[Hell Ramen], food_min_adventure_index ] = 12;
food_data[ $item[Hell Ramen], food_max_adventure_index ] = 20;
...
food_data[ $item[Knob sausage chow mein], food_fullness_index ] = 5;
food_data[ $item[Knob sausage chow mein], food_min_adventure_index ] = 18;
food_data[ $item[Knob sausage chow mein], food_max_adventure_index ] = 25;
...

int food_fullness( item food )
{
    return food_data[ food, food_fullness_index ];
}

...and so on.

I'd like to be able to do the final room of the NS lair one step at a time (so, for instance, I can face my shadow with a linoleum sword instead of a mirror shard)

Easy enough to make each of the rooms separately callable functions. But if you "for instance" is the real reason you want this, then perhaps KoLmafia should simply restore the weapon you were wielding before the energy bolt, when it wields the mirror shard.

I'd like a function like tavern() that clears the mine as cleverly as can be expected

This is more a KoLmafia suggestion rather than an ASH suggestion; this is a nice idea whether or not you are using a script.

I'd like to be able to set a parameter that says that I want to cast Saucy Salve instead of attacking when my health falls below a certain level- I'd like to be able to adapt the custom combat parameters from scripts and to write ASH-based adventures that use the CCS.

Big feature request.
 

Tirian

Member
I am, like everyone else, amazed at the power that ASH has gained over the past few weeks and months. I'm very amused at what a chimera the keyword list has become; very modern things like map access alongside constructs like downto which I haven't seen in twenty years when I was writing in Turbo Pascal. But it's all perfectly beneficial and sensible.

Holatuwol modified the chamber routine, perhaps after seeing this thread, so that it stops when it fears that you don't have enough max HP to face your shadow and it is far more intelligent about familiar training now, so I have nothing more to wish for there.

I was anticipating that sooner or later someone would write a fullness and spleenness map. Given that we now have the power of persistent variables, that's nearly all that I would want, and anything left is a broader KoLmafia expansion.

I'll tell you my design concept for the quest information, and you can let it percolate for a while. My thought is that there would be a new "quest" datatype that would enumerate the Council quests, the miscelaneous quests like the Pretentious Artist and the Felonia quests, and some things that aren't even true quests like how far you've gotten toward unlocking your guild. Then there would be two functions called something like quest_progress_to_string and quest_progress_to_int that would take a quest parameter. These functions would generally call the quest logs, and pull out the paragraph that followed the bolded name of the quest. and would return a value based on the string that it found. For instance, the Rof L'm Fao might return integers between 0 and 3 and strings like "Not granted yet", "Need to bridge chasm", "Need to reach gates", and "Quest completed". (The integer would be useful because you could say that you can adventure in the valley if the value is greater than 1.) Some checks would have to me more in-depth. For instance, if you knew from the quest log that the Trapz0r needed ore, you could grab the HTML from trapper.php and do a pattern search for "three chunks of (\w+) ore", or you could "read" the map of the Nearby Plains to see if the beanstalk had been planted.

Checking to see if an area is available for adventuring would leverage much of the logic that I described above, although other pieces would be simpler logic that would just check your stats or zodiac sign. Having the logic would provide some good benefits to the broader KoLmafia experience. For instance, the dropdown list of places to adventure would be much more informative if it only showed places that you could actually adventure.

The combat suggestion, admittedly, is huge. It might even make more sense to have a sister language (CASH?) to handle it. But I mention it because it is a wish-list and perhaps the final frontoer of KoLmafia's legitimate capabilities.

But, by all means, spend some time enjoying this marvelous playground for a while. I suspect that the persistent variables, like raw URL management in CLI, will expose some powerful functionality in the minds of the clever.
 
Wow. I had forgotten this thread even existed...

I will say, after someone goes through the effort to map out (all puns intended) all of the items and their spleen/stomach/etc. values, thanks to set_property() and get_property() it will be possible to keep track of fullness and spleen... liness?

But, only for item used during a script.

It makes me wonder if that means we are not on the cusp of Mafia doing it for us? Obviously not right away... But the info will be there.
 

Nightmist

Member
[quote author=Presto Ragu link=topic=35.msg960#msg960 date=1149147601]
I will say, after someone goes through the effort to map out (all puns intended) all of the items and their spleen/stomach/etc. values, thanks to set_property() and get_property() it will be possible to keep track of fullness and spleen... liness?
[/quote]

Theres always the problem of resetting the values every rollover. Since if you reset at the start of each script then yes that gives session based recording but then theres people that log in every now and then in the day and do a little and then log out and then later on log in again. (Then again if your scripting it then I do suppose there would be no "need" to log in multiple times per day)

Oh and I have the foods covered already thanks to a old data sheet on foods I had made ages ago in an attempt for a eating script. (Theres still a few snags in the script but it should be functional enough for now...)
 
The reset isn't too horrible... Well, at least if you are like me.

I have a script I run at the beginning of the "day" and one I run at the end.

Just set a flag that you "trip" with your initial script. And then reset it when you run your last script.

I know it isn't perfect.... But since I only ever run my closing script once a day, even if I log in again afterwards, it would work fine for me.

Others may not be so lucky.

But like I said, this is just the start. It puts most of us in the position to accurately keep track of those values. The only real thing holding us back is tracking them from items used outside of a script.

But I have had different opinions from people before... Maybe I am the only one thinking this way.
 

Tirian

Member
Wow, I'm running out of things to want. :D

One thing that would be nice is void adjust_session_results (int quantity, item it), which would tinker with the Session Results and Item Manager when you either knew something that KoLmafia didn't know or wanted to fool it for some reason.

Two samples:

Code:
void goatlet()
{
  item cheese = $item[ goat cheese ];
  while ( item_amount( cheese ) < 6 )
    adventure( 1, $location[ goatlet ]);
  if ( item_amount( cheese ) >= 6
  {
    cli_execute( "trapper.php" );
    adjust_session_results( -6, cheese );
  }
}

To recap, you know that you lost six goat cheeses when the trapper gave you the three pizzas, but KoLmafia doesn't know it because the loss of items doesn't show up in the HTML. If we can make the adjustments we know about, then it would spare us from having to do more server-intensive item refreshes.

Another example:
Code:
#...
  adjust_session_results( 1000, $item[ line ]);
  adjust_session_results( 1000, $item[ star chart ]);
  int hats_to_make = creatable_amount( $item[ star hat ]);
  adjust_session_results( -1000, $item[ line ]);
  adjust_session_results( -1000, $item[ star chart ]);
#...

Holatuwol added the ability to effectively ignore our amounts of NPC items when using creatable_amount, but this solution would give us greater flexibility. Like here, where we decided that we could ignore items that we knew would be minimum priced at the mall in any amount we could want.

---

Another thing is something that comes up here and elsewhere from time to time, which would be for KoLmafia to understand that you are starting a new day or a new ascension and clearing out caches of variables from the .kcs file. My recomendation was to clear all variables starting with __ as part of its breakfast script and all variables starting with _ when ascending which, by design, would reclear the daily variables. (I'm not married to the _ symbol but I do like the dual use idea.) I've kind of got this managed on my own, but it's something that KoLmafia can be a lot more accurate about. The power would also be useful with some of the internal variables: for instance, the tavern map would be cleared before you got to it.

Here are a few samples of how users could use this. Assume in the first case that I got my wish on leaflet( boolean ) which would run either the stat or no-stat version of the leaflet script.

Code:
void manage_leaflet()
{
  if ( my_level() < 9 || get_property( "_leaflet_status" ) == "done")
    return;
  
  if ( stat_bonus_today() != $stat[ none ] || stat_bonus_tomorrow() == $stat[ none ])
  {
    leaflet( true );
    set_property( "_leaflet_status", "done" );
  }
  else
  {
    leaflet( false );
    set_property( "_leaflet_status", "started" );
  }
}

Code:
int zaps = string_to_int( "__wand_used" );
if (zaps == 0)
{
  cli_execute( "zap boris' key");
  set_property( "__wand_used", int_to_string( zaps + 1 ));
}
 

peterbones

New member
I guess I understand what you're after with the adjust_session_results, but the goat cheese, and maybe the ores/crossbow (I think... it doesn't affect me particularly), is the only thing I can think of that screws up mafia in my use. As for the other (create amount), I guess that's something that I wouldn't ever use. Why I would encourage that this feature NOT be added is that it has the smell of the goto to me. Sure, it's more power to the user, and no one has to use it. But once people start adding it to their scripts, bad things start happening. Mafia's finally to the point where I trust it's tracking of items (aside from the aforementioned couple of things), why would I want to go screw it up?

I think entryway( boolean ) would be very nice. leaflet( boolean ) would make sense, but since I always use the words (just wait till the next day to use it sometimes) it makes little difference to me.

Mafia clearing daily variables gets a big solid 'meh' from me. If I used such a thing in the future, I'd probably still do some kind of double check in my scripts (like summoning). No offense to the developers.
 

Tirian

Member
[quote author=peterbones link=topic=35.msg1943#msg1943 date=1155690035]
I guess I understand what you're after with the adjust_session_results, but the goat cheese, and maybe the ores/crossbow (I think... it doesn't affect me particularly), is the only thing I can think of that screws up mafia in my use. As for the other (create amount), I guess that's something that I wouldn't ever use. Why I would encourage that this feature NOT be added is that it has the smell of the goto to me. Sure, it's more power to the user, and no one has to use it. But once people start adding it to their scripts, bad things start happening. Mafia's finally to the point where I trust it's tracking of items (aside from the aforementioned couple of things), why would I want to go screw it up?

I think entryway( boolean ) would be very nice. leaflet( boolean ) would make sense, but since I always use the words (just wait till the next day to use it sometimes) it makes little difference to me.

Mafia clearing daily variables gets a big solid 'meh' from me. If I used such a thing in the future, I'd probably still do some kind of double check in my scripts (like summoning). No offense to the developers.
[/quote]

As you say, you're free to not use it. But I think that ASH is already dangerous enough to burn someone who doesn't care enough to design her scripts properly. For me, the goat cheese is very major in that I find myself thinking that I have it for cooking when it's not really there, but we're also talking about quest items that disappear when the goal has been achieved. Immateria, mosquito larvae, Friar's Copse stuff, rat whiskers. Having the stuff that you don't have not show up in the Session results makes it shorter, more accurate, and clearer that you've completed a quest instead of being part of the way through it. (And who knows if combat is going to manage the items that you use.)
 
Top