Spice Loop

On days when the hermit has clovers available, it's nice to run the spice loop... for anyone not familiar with it, it goes like this:

1. Get a 10-leaf clover from the hermit.
2. Go fishing in the sewer; because of the 10 leaf clover you get your choice of 3 items from a list.
3. Pick spices, a worthless trinket, and anything else.
4. Go to step 1.

This script implements that for folks who don't need hermit permits; it runs until you have 10 turns left but that can be easily adjusted. It's also easy to make a version that purchases hermit permits for each loop, but I don't know of an easy way to automate determining if a permit is needed or not.

Code:
void go_fishing_until_worthless()
{
 while ( item_amount( $item[worthless trinket]) + 
    item_amount( $item[worthless knick-knack]) + 
    item_amount( $item[worthless gewgaw])
    < 1)
 {
  buy(1, $item[Chewing gum on a string]);
  adventure(1, $location[Sewer (unlucky)]);
 }
}

void get_clover()
{
 if( item_amount( $item[Disassembled Clover]) < 1 )
 {
  go_fishing_until_worthless();
  trade_hermit(1, $item[Ten-Leaf Clover]);
 } else {
  use( 1, $item[Disassembled Clover]);
 }
}

void onecycle()
{
 if( item_amount( $item[Ten-Leaf Clover]) < 1 )
 {
  get_clover();
 }
 if( item_amount( $item[chewing gum on a string]) < 1 )
 {
  buy(1, $item[chewing gum on a string]);
 }
 adventure(1, $location[Sewer]);
}

void main()
{
 while ( my_adventures() > 10 )
 {
  onecycle();
 }
}
 

Attachments

  • spiceloop.ash
    826 bytes · Views: 221

holatuwol

Developer
Since v6.9, KoLmafia automatically buys a hermit permit if it detects that you need one (and won't do so if you do not).  Therefore, in theory, provided you have enough meat, this script will run the same for someone who hasn't used the hermit script as it does for someone who has, except the person who hasn't will continually buy hermit permits at every trade.

Edit: And just to encourage people to consider the standard scripting engine, the above script, using the standard scripting engine.  The only downsides to this script are that it will purchase 1 extra piece of chewing gum, it assumes that you have either (a) a trinket to trade, or (b) you're in softcore and you're out of Ronin and you're willing to buy a single clover on a clover day to start the loop, rather than toy with the RNG to acquire your first trinket, and using it will not impress your friends and ... well, it uses all your adventures.

Code:
  if ten-leaf clover == 0
      retrieve ten-leaf clover
  while ten-leaf clover > 0
      buy chewing gum; adventure lucky; hermit ten-leaf clover
 

yuck foo

New member
I had a bit of trouble with the script... It barfs at the purchase chewing gum command.

So, I replaced the while my_adv statement with a while chewing gum > 0 statement. That way, I can set the number of adventures to use by how many chewing gums I buy before starting.
 

rkMerafel

New member
What is this script supposed to be used for? It didn't work with KoLMafia... what is it for?

...I'll apologise in advance for sounding like a lamz0r n00b.
 

macman104

Member
[quote author=rkMerafel link=topic=34.msg555#msg555 date=1146398085]
What is this script supposed to be used for? It didn't work with KoLMafia... what is it for?

...I'll apologise in advance for sounding like a lamz0r n00b.
[/quote]It should work with KoLMafia, are you sure it has a .ash extension on it, because it's not a standard script, its an ASH script.
 
[quote author=yuck foo link=topic=34.msg521#msg521 date=1146142657]
I had a bit of trouble with the script...  It barfs at the purchase chewing gum command.
[/quote]

Hmmm... that portion has certainly worked fine for me. What does the barf look like?
 
[quote author=macman104 link=topic=34.msg556#msg556 date=1146399230]
It should work with KoLMafia, are you sure it has a .ash extension on it, because it's not a standard script, its an ASH script.
[/quote]

Yeah, what he said. Other things to check:
- Is the script in the correct directory? It should be in the scripts directory within the folder that contains KoLmafia.
- If you open up the script in a text editor (like notepad or something) does it look the same as what's posted in the forum?
- If you did a cut-and-paste of the script, try using the download link instead.
 

rkMerafel

New member
Yeah, I cut and pasted it into a .txt file then tried to run that.

Sorry for being an arse. Thanks for the help.

EDIT: Mine also "barfs" at the chewy bit. It just says "Ran out of chewing gum" and stops. Could you make it so it automatically buys a new one? I've temporarily fixed it by buying 1000 chewies, but it'd be nice if it did it automatically.

EDIT EDIT: When I finished my 200 adventures running the loop, I got this: http://i3.tinypic.com/wvu62w.jpg
Why didn't I get 200 of each?
 
[quote author=rkMerafel link=topic=34.msg584#msg584 date=1146479953]
Yeah, I cut and pasted it into a .txt file then tried to run that.

Sorry for being an arse. Thanks for the help.

EDIT: Mine also "barfs" at the chewy bit. It just says "Ran out of chewing gum" and stops. Could you make it so it automatically buys a new one? I've temporarily fixed it by buying 1000 chewies, but it'd be nice if it did it automatically.

EDIT EDIT: When I finished my 200 adventures running the loop, I got this: http://i3.tinypic.com/wvu62w.jpg
Why didn't I get 200 of each?
[/quote]

Re: Edit
I can see no reason why it would "barf" at the chewing gum part. Could you please post any error message you recieve?

Re Edit Edit
Please check your inventory in the relay browser or IE directly. In the past kolmafia's counters have gone screwy, and this might be the case. Also check to see if it actually used 200 adventures. everything I see says the script should run flawlessly.

In the image posted, it shows 803 chewing gum gained. It only shows 90 meat used. Either you got one hell of a discount on the chewing gum, or the counters in kolmafia were thrown askew by something. Definately check your inventory, and number of adventures remaining. Also try to remember if maybe you did other things you haven't mentioned.
 
[quote author=efilnikufecin link=topic=34.msg585#msg585 date=1146506415]
I can see no reason why it would "barf" at the chewing gum part. Could you please post any error message you recieve?[/quote]

I found it, it's a bug in KoLmafia, not my script.

[quote author=efilnikufecin]
Please check your inventory in the relay browser or IE directly. In the past kolmafia's counters have gone screwy, and this might be the case. Also check to see if it actually used 200 adventures. everything I see says the script should run flawlessly.
[/quote]

The bug goes like this: Each adventure at the Lucky sewer decrements KoLmafia's counters for Adventures and Chewing Gum twice. So the first time through the loop, it works but it ends up with an inventory count of -1 chewing gum. My script then buys another gum, bringing KoLmafia's idea about how much gum it has up to zero, and then it attempts to go to the sewer again and KoLmafia, thinking we have zero gum (when in fact we have one) prints the ran out of gum message.

If you buy a whole load of chewing gum in advance, it works fine but with two issues:

1) It appears to consume twice as many turns as it really does.
2) It appears to consume twice as many chewing gums as it really does.

I'm writing up an email to holatuwol right now; in the mean time the workaround is to just buy the gum in advance and refresh status and inventory afterwards.

Edit: And thank you very much to rkMerafel for providing such a useful bug report! Having the exact error message and the screenshot and everything really helped me locate this quickly. :)
 
OK so a temporary patch would be to do a status refresh to give kolmafia accurate count of advenrures. buying gum in advance will need to be done. Let's hope this bug is fixed in version 7.2
 

rkMerafel

New member
Re bug report: you're most welcome.

I originally bought 1000 chewies, obviously for 30,000 meat. It said I lost 200 of them whilst only gaining 100 spices. I will admit I did not check my inventory or anything afterwards or the number of adventures I had remaining. Today I logged on and found I did indeed had 100 left over adventures.

So the way to get around that would be just to restart the script, or should I log out and then in again?

By the way, I would have mentioned any mitigating circumstances. I'm not that much of a newb.
 
[quote author=rkMerafel link=topic=34.msg604#msg604 date=1146570455]
Re bug report: you're most welcome.

I originally bought 1000 chewies, obviously for 30,000 meat. It said I lost 200 of them whilst only gaining 100 spices. I will admit I did not check my inventory or anything afterwards or the number of adventures I had remaining. Today I logged on and found I did indeed had 100 left over adventures.

So the way to get around that would be just to restart the script, or should I log out and then in again?

By the way, I would have mentioned any mitigating circumstances. I'm not that much of a newb.
[/quote]

in void main:
void main()
{
while ( my_adventures() > 10 )
{
onecycle();
cli_execute("status refresh");
}
}
The cli_execute("status refresh"); command will re synchronize kolmafia's counters with kol for adventures anyway. The # of chewing gum would require an inventory refresh, but with so many on hand, resynchronizing that counter should be unimportant to you.
 
Just as an FYI, the fix for this problem isn't in 7.2; which is not surprising as I didn't report the bug to Holatuwol until a few hours at most before he released the new version.
 

bambababy

New member
well...
I'm kinda new in this form of scripting. but i let myself change your script a bit.
I just added the option to put the number of adventures you want to do the spice loop.

:)
 

Attachments

  • spiceloop.ash
    1 KB · Views: 129
can you update your program to work with version 8.3? some locations and things have different names, like the sewers, and i dont know how to change them. excuse me for sounding like a n00b, but i dont think i have the programs necessary to create/alter .ash stripts, and kolmafia won't let me alter existing ones either, as far as i can tell.
 

Nightmist

Member
[quote author=phoenixflames125 link=topic=34.msg1653#msg1653 date=1153621469]
excuse me for sounding like a n00b, but i dont think i have the programs necessary to create/alter .ash stripts, and kolmafia won't let me alter existing ones either, as far as i can tell.
[/quote]

Open with a text editor, if your using a default install of windows you should have something like notepad//wordpad. (ASH is effectively a plain text file)
 

Pyro Kittens

New member
using 8.6 I believe, it gives me the error: Location Sewer: Unlucky Sewer not found in database, yes I did some editing because "Sewer (unlucky)" was no longer the name. An update would be cool.
 
Top