PDA

View Full Version : CounterChecker: Wormwood, Semi-rares, Dance Cards and more



Pages : [1] 2 3

Bale
09-05-2009, 07:51 AM
CounterChecker 1.49996
This version requires and is required for the latest version of KolMafia here (http://builds.kolmafia.us/).

This script will automatically handle all your counters automatically. It contains all the features of previously shared counter scripts, plus more! Supported Counters:

Fortune Cookie: If you're not in hardcore it will get the available semi-rare with highest mall price.
Wormwood: Will automatically get the wormwood goal of your choice. You can set the goal in CLI with: set wormwood = goal
Dance Card: Will adventure in Ballroom, if you're not already there and use another dance card.
CLI: You can delay execution of a CLI command. To defer it for <num> turns, type this in the CLI:
counters add <num> cli <command>
Dude Ranch Vacation, Tropical Island Vacation, Ski Resort Vacation: Will abort automatic adventuring and alert you that the vacation is ready to produce a tower item, but it will not adventure there automatically so you can purposefully schedule those 3 turns.


To use:

Put this script in your /scripts directory
Download zlib (http://kolmafia.us/showthread.php?t=2072) and put it in your /scripts directory
zlib is used for a lot of other scripts, so you might already have it. ;)
In the CLI use the command:
set counterScript = CounterChecker.ash
If you're using absinthe, you'll probably want to set your wormwood goal.
Use the command set wormwood = goal

More detailed instructions in the following post.

Bale
09-05-2009, 07:52 AM
Automatic Wormwood adventuring:
If using absinthe, you can set your goal to be any wormwood prize or stat. You can add 51 or 1 to a stat to limit the turns you spend on your stat adventures. This script is very good at figuring out what you mean, so you can just type "cancan", "skirt" or "pants" to get a can-can skirt. Lots of abbreviations will work. You'd be surprised how you can improvise and still get the prize you desire. If you do not set your wormwood goal, then the script will assume you want a not-a-pipe. set wormwood = !pipe
set wormwood = mask
set wormwood = hat
set wormwood = moxie 5-1
set wormwood = myst1
set wormwood = Mysticality
set wormwood = pants
set wormwood = s.t.l.t
set wormwood = stlt
set wormwood = food


Options:
All options will be saved to a file specific to the character so that each character can have different variables. This file is in your /data directory and is named vars_<character>, where <character> is the character's name.
BaleCC_SrInHC: Automate Semi-rares in Hardcore and Ronin. If this is false, then you won't have to worry about CounterChecker determining your semi-rares for you while ascending.
BaleCC_useDanceCards: Use another dance card after going to the Ballroom for Dancing Matilda.
BaleCC_ImprovePoolSkills: If you are automating semi-rares, then instead of choosing an expensive semi-rare item, your character will improve his chance of winning at the VIP Pool Table.


Changelog:
v1.1 Sept 9, 2009
- Now, if you have the script set to ignore semi-rares in hardcore, it will also ignore them in ronin. The script is now completely ascension safe.

v1.2 Sept 14, 2009
- Fix for not having basement access in your clan
- Now it can handle negative counters. (For compatibility with future kolMafia feature.)

v1.3 April 20, 2010
- Fixes for various bugs.
- Adds consideration for distilled fortified wine, tasty tarts and scented massage oil.
- Reports current sale price of semi-rare that it automates.

v1.4 October 18.2010
- Update for compatibility with zarqon's BBB.

v1.41 January 26, 2011
- Maintenance update for change to Friar's Quest

v1.49 February 1, 2011
- Added checks for every single semi-rare
- Proper checks to see if each semi-rare is currently accessible

v1.491 February 1, 2011
- Fixes for continuum transfunctioner and stench resistance where needed

v1.492 February 1, 2011
- Final fix to stench resistance for myst classes. Thanks, Theraze.

v1.493 February 11, 2011
- Fix unlocked locations bug.

v1.494 February 12, 2011
- Fix CanAdv check for Limerick Dungeon.

v1.495 February 13, 2011
- Small code improvement. Not even a bug.

v1.496 February 16, 2011
- Fix adventuring check for KoL's Cobb's Knob revamp.

Bale
09-05-2009, 07:56 AM
Okay, I'm not really certain that we really need another counter checker, but this one wraps up all generally used counters in a single script, so the user won't have to download 3 different scripts and possibly get confused. It does require Zarqon's zlib, but most scripts require that nowadays, so it isn't an unusual requirement. (Thanks for zlib, Zarqon.)

Also, this script plays nice with the counters that my recovery script (http://kolmafia.us/showthread.php?t=1780) will invoke, so that little bit of interactivity between my scripts is nice.

I'm also proud of the fact that when setting my wormwood goal I don't have to remember the correct name for the objective. It is hard to type something so wrong that this script won't recognize it. If someone does manage to mess it up, without truly egregious typos, then please let me know so that I can add that as an option.

flypapermonk
09-12-2009, 05:52 PM
Two questions:

1) Will I have to rewrite my farming script to eat a cookie every day (note: I have never eaten a cookie) or will Mafia somehow automatically invoke this script as needed?

2) Will this interrupt normal adventuring to go get a semirare?

halfvoid
09-12-2009, 09:25 PM
Tried this out the other day while farming the stately pleasure dome and it never switched to the other locations to get the not a pipe. i'm not entirely sure if i set it up correctly by using counterscript = counterkeeper.ash in the CLI though.

Bale
09-12-2009, 10:07 PM
Will I have to rewrite my farming script to eat a cookie every day (note: I have never eaten a cookie) or will Mafia somehow automatically invoke this script as needed?It will automatically eat a cookie after every time it gets a semi-rare, so you'll have to leave some empty space in your tummy if you want it to eat fortune cookies for you. However, you'll have to eat that first one yourself if you want it to get started.


Will this interrupt normal adventuring to go get a semirare?Yes, it will. However if you are in hardcore or ronin it won't do that unless you change the default setting.


Tried this out the other day while farming the stately pleasure dome and it never switched to the other locations to get the not a pipe. i'm not entirely sure if i set it up correctly by using counterscript = counterkeeper.ash in the CLI though.Ah. Actually that's because mafia won't initiate a counterscript if you're already in a zone that the counter is attuned to. This is also an issue for not triggering dance card counters in the ballroom, so it won't know to use a new dance card. Perhaps I should report this as an issue to the mafia devs, though I think they probably consider it a feature... Sorry, there's no way for me to cause the script to activate for absinthe usage if you're in an absinthe zone. I'll report this and ask for a change to mafia.

Edit: Asked for a change to mafia's counter behavior here (http://kolmafia.us/project.php?issueid=742).

flypapermonk
09-12-2009, 10:51 PM
Okay, one last question:

I know that if you try to eat a cookie immediately after getting a semirare it will give you totally random numbers until you re-seed the counter by accessing adventure.php. As I was poking around in your code, it did not seem like you were doing this but were just immediately eating a cookie after getting the semirare. Am I wrong or should I try to tweak the code a little to add an adventure before eating the next cookie?

Bale
09-12-2009, 10:53 PM
You are mistaken. If you eat a cookie immediately after getting a semi-rare it works just fine.

The situation in which your numbers are meaningless are if you eat the cookie without accessing adventure.php since rollover, login or ascension. (Getting a semi-rare is a visit to adventure.php and takes care of things perfectly.) Trust me that my script works since I've had a character generating semi-rares only by eating the cookie that is automatically eaten by the script.

flypapermonk
09-13-2009, 10:13 AM
Just a heads up, this script breaks if your clan has a clan basement and you are not allowed in. I added a check to make sure you are allowed.



// This finds out if the PLD can be accessed for semi-rare usage.
if(last != "The Purple Light District") {
if(visit_url("town_clan.php").contains_text("clanbasement.gif") && !visit_url("clan_basement.php?fromabove=1").contains_text("not allowed")) {


This seems to fix it, but I'm not sure if there are other circumstances that break it.

Bale
09-13-2009, 05:15 PM
I see. Thanks for that. I'll add it when I have a chance.

ziz
09-16-2009, 02:05 PM
Thanks for this - I've been using a slightly modified cookie.ash (from http://kolmafia.us/project.php?issueid=184) for a while, and have been very happy with it (although, amusingly, it almost never /does/ anything for me, since I'm only rarely in aftercore). Looking forward to increased functionality!

Paragon
09-23-2009, 08:54 PM
Will this resume adventuring in the original zone after the counter hits? For example lets say that I am used adv * gallery with 40 adventures, the cookie counter expires after 10 adventures, will it automaticly continue adventuring in the gallery for the next 29 adventures? Or would I have to manually restart the gallery adventuring?

Bale
09-23-2009, 09:57 PM
Yes, it will do that.

Actually, now that jason changed counter handling in r7639, several other problems, like halfvoid's issue have disappeared. The script should now be able to get absinth if you're adventuring wormwood and use dance cards if you're in the ballroom.

I've uploaded my latest version which is better at handling informational counters that go negative. (That can happen thanks to jason's update in r7639.)

That FN Ninja
09-23-2009, 09:57 PM
It will continue adventuring.

Edit: wow, at exactly the same time! Thanks for the script Bale!

jasonharper
09-23-2009, 11:47 PM
adv * gallery with 40 adventures, the cookie counter expires after 10 adventures, will it automaticly continue adventuring in the gallery for the next 29 adventures?
It will continue for the next 30 adventures - turns spent by a counterScript don't count towards your original request.

mredge73
09-25-2009, 02:25 PM
Bale I have a request:
When more than one counter expires on the same adventure can the cookie counter take priority? I have missed more than one semi-rare this way while trying to level my disco bandit with dance cards or tiny bottles. The dance cards and bottles are a much cheaper sacrifice than a semi-rare.




Request 6 of 50 (Hobopolis: Hobopolis Town Square) in progress...
Checking counters now.

Visit to Knob: Outskirts of The Knob in progress...
Checking counters now.

Visit to Manor2: Haunted Ballroom in progress...

[5583] Haunted Ballroom
Encounter: Rotting Matilda
You gain 293 Sarcasm

Using 1 dance card...
Finished using 1 dance card.

[5584] Outskirts of The Knob
Encounter: sleeping Knob Goblin Guard
Strategy: d:\Data\My Stuff\kol\Kol Mafia\ccs\sewer.ccs [default]
Round 0: alotavagina wins initiative!
Round 1: alotavagina tries to steal an item!
You acquire an item: Knob Goblin scimitar
Round 2: alotavagina attacks!
Round 2: sleeping knob goblin guard takes 211 damage.
You gain 5 Meat
You acquire an item: viking helmet
You acquire an item: Knob Goblin pants
You gain 4 Beefiness
You gain 5 Enchantedness
You gain 9 Sarcasm

Oops, that wasn't the right number!

Bale
09-25-2009, 04:25 PM
Bale I have a request:
When more than one counter expires on the same adventure can the cookie counter take priority? I have missed more than one semi-rare this way while trying to level my disco bandit with dance cards or tiny bottles. The dance cards and bottles are a much cheaper sacrifice than a semi-rare.

More than reasonable. Now semi-rares take priority. I didn't bother updating the version number in the thread for this little change so it won't trigger an update warning, but internally it is v1.21 now.

ziz
09-25-2009, 04:43 PM
1.21 gigacounters, 88 turns per hour...We're going back! BACK TO THE FUTURE!

mredge73
09-26-2009, 01:03 PM
sweet update
hey bale is counterchecker.ash the official name now?
I was using counterkeeper.ash before.

Bale
09-26-2009, 07:17 PM
CounterChecker is the official name now. It was keeper briefly before I made this thread. (I went through a lot of names... this one won... barely.) Glad you like it.

notusername
09-29-2009, 06:03 PM
There seems to be a small problem with ImprovePoolSkills, in that it seems to always adventure at the Haunted Billiards Room when enabled despite that one can not get A Shark's Chum on consecutive occasions (I attempted this on 4 separate counter expirations, but yeah, playing "at every opportunity" does not seem to work).

I suspect that the whole option may be reworked, because the locale in "if(ImprovePoolSkills && locale != $location[Haunted Billiards Room])" references expensive_semi(), which will not return the Haunted Billiards Room on most occasions (or ever, if it was the last semi-rare obtained). Perhaps another check in expensive_semi() along the lines of the PLD check? If last != HBR && ImprovePoolSkills, always return HBR, otherwise perform the normal check for most expensive?

I was just trying this option out and noticed this, but great work as always.

Bale
09-29-2009, 09:27 PM
Oh heck. You're quite right! It was actually easier to fix than you suggest.

I've been meaning to rewrite it to take advantage of zlib's new ability to set variables. As soon as I can do that, I'll update the first post. For now you can use the version I'm attaching right here.

Bale
09-30-2009, 05:34 AM
Oops. That last update doesn't work. It'll work now if you download this:

mredge73
10-01-2009, 01:45 PM
Hey Bale
I need a little help improving this function:
http://kolmafia.us/showthread.php?t=2039&highlight=semirare&page=2
due to this update:
http://kolmafia.us/showthread.php?t=2621&highlight=relaycounters

I noticed that your script checks the "semirareCounter" property, this property did not exist when I created my original script. Is this a user created property that you put in or is it a new mafia feature?

Do you know how to use the ash string get_counters(string, int, int) function? I cannot find an explanation of its use to know what parameters to pass to it.

thanks

Bale
10-01-2009, 09:03 PM
get_property("semirareCounter") will return the turn on which you got your last semi-rare. This is a mafia feature, not something I did.

Information on get_counters() is in the changelog for r7511.


string get_counters(string label, int minTurns, int maxTurns)

label: counter to test for. An empty string will match any counter that takes an action. In other words, "" will match everything except for Communications Windchimes, PADL Phone or a user created non-action counter.

minTurns and maxTurns specify the endpoints (inclusive) of the range to be
checked. Passing the same value for both checks for an expiration on that
specific turn.

The function will test to see if any active counters match label. Return value is an empty string if no matching counters were found. If counters are found it returns a tab-delimited list.

If you need any more help on your script, rest assured that I'll notice it if you post in your thread.

mredge73
10-02-2009, 02:34 PM
Bale
Back to your script...

Is there a way to have counterchecker.ash abort if it encounters a counter that your script does not directly support.

For example:



Request 20 of 25 (BatHole: Boss Bat's Lair) in progress...
(Harold's Bell counter expired)
Checking for updates (running CounterChecker ver. 1.2)...
_version_BaleCC => 1.2
Checking counters now.
It is time to do something because your Harold's Bell counter is up.

[577] Boss Bat's Lair
Encounter: The Boss Bat
Strategy: d:\Data\My Stuff\kol\Kol Mafia\ccs\pastaman.ccs [default]
Round 0: mredge73 wins initiative!
Running Zarqon's FTF
Round 1: mredge73 casts ENTANGLING NOODLES!
Casual Combat, re-revamped.
Round 2: mredge73 casts RAVIOLI SHURIKENS!
Round 2: the boss bat takes 38 damage.
Round 3: mredge73 casts RAVIOLI SHURIKENS!
Round 3: 6 Months Off Work dances the bossa-gnova, tipping you a wignk as he finishes with a flourish.
Round 3: the boss bat takes 38 damage.
You acquire an item: dense meat stack
You acquire an item: Boss Bat bandana
You gain 1 Strongness
You gain 5 Magicalness
You gain 2 Sarcasm
Combat finished!

Request 21 of 25 (BatHole: Boss Bat's Lair) in progress...
You can't get to that area.


In the above case I did not have my ML adjusted properly to get the reward from Boss Bat. The counterchecker.ash came up but did not stop the auto-adventuring.

Is there a way to throw an abort that would stop adventuring in this case?
Or would the abort just abort your script?
This could also be useful is someone would make their own counters and wanted to do something when they expired.

Bale
10-02-2009, 04:51 PM
harold's bell is an informational counter. That means mafia won't automatically stop adventuring there. However if you're writing your own counterScript you have all kinds of options. The simplest is to throw an abort which would stop autoadventuring. However, if you know that you always use the bell in the batcave, you can have it automatically adjust the MCD for you when the counter is done.

I think in this case, you should just check the length of the counter and only adventure that many turns.

If you make your own counters, then unless you specifically made them a no-action informational counter, all you have to do to have them stop autoadventure is to return false. This script returns false for all unknown counters, so it would stop on such things, unless they are like Harold's Bell.

mredge73
10-04-2009, 11:24 PM
damn

the counter choose the dance card over the semi rare counter again


Request 129 of 150 (Hobopolis: Hobopolis Town Square) in progress...
Checking counters now.

Visit to Hobopolis: The Purple Light District in progress...
Checking counters now.

Visit to Manor2: Haunted Ballroom in progress...

[7552] Haunted Ballroom
Encounter: Rotting Matilda
You gain 307 Roguishness

Using 1 dance card...
Finished using 1 dance card.

[7553] The Purple Light District
Encounter: Van, Damn
Manual control requested for choice #205

Bale
10-05-2009, 02:35 AM
Wait, that doesn't seem possible if you're using a version downloaded since I made the change. Please check the first line of your copy of my script for the version number. Let me know what it says.

mredge73
10-05-2009, 02:23 PM
// CounterChecker v1.22

Bale
10-05-2009, 09:59 PM
Oh. Of course. I don't know what I was thinking about. Of course my script cannot control the order that counters are checked. Mafia decides what counter is being checked when it calls the counterScript.

Please report this as a suggestion in the bug report forum here (http://kolmafia.us/project.php?do=issuelist&projectid=1&issuetypeid=bug).

Spiny
10-12-2009, 10:38 AM
Hey Bale, just a note....

I used this script tonight for first time to collect some !pipes while farming castle. I noticed it takes 11 turns instead of 10... is this because of some limitation in mafia that a new absinthe bottle can't be used right after collecting the pipe? Also, it's giving me little "Time has expired for you to adventure in Wormwood for !pipe" messages.... I think this is due to the change in how the counter itself is handled... but this is just cosmetic... the script rocks for collecting pipes though, so thanks :D If there's a fix to get it to be 10 turns rather than 11, that would be cool too ;)

That FN Ninja
10-12-2009, 07:56 PM
Thanks for this script Bale! Now I almost never miss a semi-rare. :D One thing though. I have a script that gets the steel organ item for me and I was adventuring at the gate in an attempt to get the steel organ item when CounterChecker aborted my script because the steel organ counter expired. Maybe you could set it up so that if the steel organ counter expires and someone is already adventuring at Friar's Gate it doesn't abort?

Edit: Never mind. Sorry, CounterChecker didn't abort the script I just thought it did. My bad.

Bale
10-12-2009, 09:49 PM
I used this script tonight for first time to collect some !pipes while farming castle. I noticed it takes 11 turns instead of 10... is this because of some limitation in mafia that a new absinthe bottle can't be used right after collecting the pipe?
I seem to remember someone making a complaint about that, but I cannot remember what Jason said in response...

captdrain
10-20-2009, 08:08 AM
Hi Bale,

Thanks for a great addon. It used to work flawlessly for me but lately I have been getting this error where the script checks for the counter then decides to carry on farming in the last location I was farming in (in this case, castle):

"Visit to Beanstalk: Giant's Castle in progress...
Checking for updates (running CounterChecker ver. 1.2)...
_version_BaleCC => 1.2
Checking counters now.
Searching for "cube of billiard chalk"...
Searching for "irradiated pet snacks"...
Searching for "knob goblin lunchbox"...
1 none does not exist in the adventure database.
Oops, that wasn't the right number!

[79181] Giant's Castle
Encounter: All The Rave
You acquire an item: Mick's IcyVapoHotness Inhaler"

Any idea what I did wrong?

thanks again.

Bale
10-20-2009, 08:39 AM
That looks like I did something wrong, not you... It's tough to figure out what went wrong, so bereft of any other choice I've added some debugging code to the program. Please switch to the new version and if it goes bad again it will abort rather than let you get screwed up. It will also print some data for you to report to me.

Good luck.

captdrain
10-21-2009, 08:36 AM
Oh ok thanks!

Tried the new version out. Got this message:

"Request 110 of 227 (Beanstalk: Giant's Castle) in progress...
Checking for updates (running CounterChecker ver. 1.25)...
_version_BaleCC => 1.25
Checking counters now.
Searching for "cube of billiard chalk"...
Searching for "cyclops eyedrops"...
Searching for "knob goblin lunchbox"...
Something went wrong determing the best semi-rare. Please copy-paste this output to http://kolmafia.us/showthread.php?t=2519
cube of billiard chalk sells for 7800 meat.
cyclops eyedrops sells for 22899 meat.
Knob Goblin lunchbox sells for 25549 meat.
Please continue manually. Sorry for the bug."

Hope that helps!

Bale
10-21-2009, 09:22 AM
That actually did help. Found the blasted bug and uploaded a fixed version in the first post. Thanks for your patience.

Raven434
12-18-2009, 01:24 PM
I have recently started to have these kinds of 'negative' counter counts.

The build is 7889. Using the CounterChecker.

Last semirare found -1751 turns ago (on turn 64403) in Giant's Castle

No active counters.

> eat fortu

Purchasing fortune cookie (1 @ 40)...
You acquire an item: fortune cookie
You spent 40 Meat
Purchases complete.
Eating 1 fortune cookie...
You gain 1 Adventure
Lucky numbers: 65, 288, 147
Lucky number 65 ignored - too soon to be a semirare.
Lucky number 288 ignored - too soon to be a semirare.
Lucky number 147 ignored - too soon to be a semirare.
Finished eating 1 fortune cookie.

How do I reset the internal counters or how do I fix this error? Mod the prefs.txt file?

Thanks.

lostcalpolydude
12-18-2009, 03:43 PM
The value you need to change is semirareCounter which is the turncount of your last semirare that mafia knows about. Setting it to blank is probably the best option.

codster62
01-17-2010, 04:30 PM
>.< I am confused as how to set this up. I downloaded the script and put it in my scripts directory, started kolmafia and logged in with my character, then set my counter script to your script using the cli. I then went to the vars_coolbufferbot.txt and there were none of your scripts options there... What am I doing wrong.. If you don't mind, can you give me step-by-step instructions on how to set this up? Sorry, I am an idiot, lol.

Bale
01-17-2010, 05:01 PM
Until the first time it runs, variables won't be put into your vars file. If you want to add those variables so that you can edit them easily (before your counter comes up), you can run the program from the menu. It will ask you for a string and an int. The answers aren't very important as long as you input nonsense that it doesn't know how to deal with.

Step-by-step:

In the program menu: Scripts -> CounterChecker.ash
Please input a value for string name: HI
Please input a value for int remain: 33
Edit vars_coolbufferbot.txt

codster62
01-17-2010, 06:05 PM
Weird... I tried this again, and it still won't place them there. I did exactly as you said...

> call scripts/CounterChecker.ash

Checking counters now.
In 33 turns it will be time to do something when your HI counter is up.
You'll need to kill some time until then since the current action requires more than 1 turn.

Then I went to edit my vars and nothing... Can I manually add the things to my vars?

EDIT: Also, I noticed in my data folder for some reason there are two different sets to my character vars. One with all lowercase, coolbufferbot_vars.txt, and one with capitalization, Coolbufferbot_vars.txt. I checked both of them and neither have the variables from the script...

EDIT2: After looking at the scripts contents, I see that is has three lines with those boolean variables, and tells them to be editable in the vars for my character. Instead of

boolean srInHC = vars["BaleCC_SrInHC"].to_boolean();

boolean useDanceCards = vars["BaleCC_useDanceCards"].to_boolean();

boolean ImprovePoolSkills = vars["BaleCC_ImprovePoolSkills"].to_boolean();


Instead of what is above in the script, can I edit it to make it say what is below? I really have no clue, sorry...

boolean srInHC = True
boolean useDanceCards = False
boolean ImprovePoolSkills = False

Grotfang
01-17-2010, 08:07 PM
EDIT2: After looking at the scripts contents, I see that is has three lines with those boolean variables, and tells them to be editable in the vars for my character.

You could hard code the values, if you so wished - however, I would not recommend that. Alternatives:

Find where it says:


setvar("BaleCC_SrInHC", FALSE);
setvar("BaleCC_useDanceCards", TRUE);
setvar("BaleCC_ImprovePoolSkills", FALSE);

These are the default values. Since they haven't come up yet, they won't exist in your data vars file. To change them, simply edit them according to needs.

Alternatively, add the lines yourself to your data file. The script will (I believe) only use the default settings if alternatives are NOT present in your variables file. If you pre-empt the script, that will also set them appropriately.

Bale
01-17-2010, 08:35 PM
Yes, you can edit the values into vars_coolbufferbot.txt manually. Just remember to put a tab between the variables and their values.

The only reason I can imagine for them not being added to vars when you ran the script is because your text editor was still open with the vars file when you ran it.

Editing the script the way you suggest would do what you want, but it would force all your characters to use the same settings. (Don't forget the semi-colons at the end of each line.)

codster62
01-17-2010, 08:40 PM
Okeydoke. Thanks for the help.

slyz
01-17-2010, 10:23 PM
I got a Pixie recently and started using this script for the wormwood part after testing it out manually a few times.

Just... wow =)

Thanks a lot!

Bale
01-17-2010, 11:30 PM
Now that's the kind of appreciation that makes my day. :D

Dingamagoo
01-23-2010, 03:34 AM
Been using this script and your recovery script: revolutionized the way I play.

A doubt lingers though: does the cost calculation take into account SRs that give you more than 1 item?

I'm not sure, but I have the feeling it sometimes went for SRs which items were below the price of 3 times "massage oils".

Might be that I checked the mall when the prices had already changed.

If you clear it up, I may even get my head into trying to change the script and become a writer myself.

Bale
01-23-2010, 04:56 AM
I admit that I'm only checking the price for the "usual suspects."


If you clear it up, I may even get my head into trying to change the script and become a writer myself.

Well, then, the part where I point out the semi-rares I check for price is here:


item [location] semi_rare;
semi_rare[$location[The Purple Light District]] = $item[lewd playing card];
semi_rare[$location[Haunted Billiards Room]] = $item[cube of billiard chalk];
semi_rare[$location[Menagerie 2]] = $item[irradiated pet snacks];
semi_rare[$location[Outskirts of The Knob]] = $item[Knob Goblin lunchbox];
semi_rare[$location[Limerick Dungeon]] = $item[cyclops eyedrops];
I then remove from consideration any item that was the most recent semi-rare:


remove semi_rare[last.to_location()];

Here's the code to find the best buy, you'd need a special exception to multiply the price of massage oil, tarts or distilled wine by three. Bonus points for comparing the price of a lunchbox vs the price of the contents of that lunch box.

int [item] prices;
int expensive = 0;
location best = $location[none];
foreach locale, rare in semi_rare {
if(historical_age(rare) > 1 || historical_price(rare) == 0)
mall_price(rare);
if(historical_price(rare) > expensive) {
best = locale;
expensive = historical_price(rare);
}
}

It wouldn't take much work to add in every semi-rare. It just never seemed interesting since I only ever noticed those 5 vying for position as most expensive.

Dingamagoo
01-23-2010, 08:16 PM
Ah, thx.

Let's see if I'm reading the code correctly.

I'll use the massage oils as the example.

I have to add something like this to the list of items:


semi_rare[$location[Knob Goblin Harem]] = $item[scented massage oil];

And change this:


if(historical_price(rare) > expensive) {

To something like this (ignore the syntax, 'cause I think '*' actually means "all", not "multiply" and I'm using '&&' because of the '||' analogy from C, and the extra parentheses may be useless if this scripting language is like java in evaluating Boolean expressions... *inhale*):


if(historical_price(rare) > expensive || (rare == $item[scented massage oil] && historical_price(rare) * 3 > expensive)) {

Is anything fundamentally wrong in my approach to the problem?

I suspect that PriceAdvisor already takes care of the Lunchbox vs Contents calculation issue or at least has the necessary code to do it that I can strip from there.

aqualectrix
01-23-2010, 08:44 PM
PriceAdvisor is a rather big stick to swing at just one item.

I can tell you from experience that the expected value of the contents (1.5 * pasty price + 1.5 * thermos price) is nearly always greater than the price of the lunchbox. Of course, it's usually safer to have the code do the calculation and decide from there, so to value the lunchbox you probably want something like this:

max(historical_price($item[lunchbox]),
1.5 * (historical_price($item[knob pasty]) + historical_price($item[knob coffee])))

Bale
02-03-2010, 08:32 PM
Script Updated!

Update KolMafia here (http://builds.kolmafia.us/). r8068 or later is now required.

r8048 added a new feature giving pop-ups when you eat without milk. That means after getting a semi-rare you'll be interrupted by a pop-up asking for permission to eat a fortune cookie without milk of magnesium. Since it is troublesome to have your automation interrupted, a new command was added in r8068 to eat without that pop-up.

The script now uses the new eatsilent command to eat fortune cookies without interrupting your automation.

tgetgel
02-08-2010, 02:49 PM
When adventures are used to recover HP, counterchecker.ash and resting on the clan sofa do not play well together.


Executing request...
Checking for updates (running CounterChecker ver. 1.27)...
_version_BaleCC => 1.27
You have a current version of CounterChecker.
Checking counters now.
Searching for "cube of billiard chalk"...
Searching for "cyclops eyedrops"...
Searching for "irradiated pet snacks"...
Executing request...

[28847] Rest in Clan Sofa (3 turns)
You gain 434 hit points
Resting completed.

[28850] Menagerie 2
Encounter: Carnivorous Moxie Weed
Strategy: C:\Program Files\KoLMafia\ccs\default.ccs [default]
Round 0: (insert name here) wins initiative!
Round 1: (insert name here) tries to steal an item! (auto-attack)
You lose 1,716 hit points
You acquire an item: moxie weed

Oops, that wasn't the right number!

[28851] Rest in Clan Sofa (3 turns)
You gain 434 hit points
Resting completed.

> counters

Last semirare found 176 turns ago (on turn 28677) in Outskirts of The Knob

No active counters.

The healing from resting on the clan sofa would not be needed if the number were right (meaning that you don't take damage when finding a semi-rare). The number is wrong because of the resting on the sofa in the middle of the counter checker. Is there a way to mask the interrupt from Mafia for recovering via the clan sofa in the middle of the counter checking script?

I know that I might miss the counter if the rest command happens a turn or two before the counter expires and it rests 3 times. Is there a way to get Mafia to rest only one adv at a time instead of 3 at a time?

I know that using Bale's Universal Recovery Script would take care of this, but I am running this for someone that does not want to spend money on healing. Maybe that just means that they do not get the benefits of getting the semi-rares either.

slyz
02-08-2010, 05:20 PM
I think that's a problem with Mafia and counters in general more than with this script. Mafia knows when something is going to take more than one turn, and if that risks using up a counter. But since this is happening after the counter has launched the script, Mafia doesn't consider it anymore. There's no way for CounterChecker to override this.

My opinion would be not to use precious adventures to heal though =) (check out another script from Bale, Unversal Recovey (http://kolmafia.us/showthread.php?t=1780)).

tgetgel
02-08-2010, 08:08 PM
My opinion would be not to use precious adventures to heal though =) (check out another script from Bale, Unversal Recovey (http://kolmafia.us/showthread.php?t=1780)).

I use Bale's script for my character, but for this other one I am just following the doctors orders.

Bale
02-08-2010, 10:42 PM
How interesting...

I suppose I could disable your healing options temporarily, check for the semi-rare and then re-enable your auto healing, but I don't think that is really a good idea.

My advice is to never automatically use adventures for healing. I cannot think of an instance in aftercore when that could possibly be better to lose 3 adventures rather than purchase restoratives from the mall. That's just insane. If you're in hardcore or ronin, you never want adventures to disappear without notice so it should be done manually if you need it.

IN other news, WTF? You lose 1,716 hit points from a carniverous moxie weed? Was that slime damage?

tgetgel
02-09-2010, 03:06 AM
How interesting...
IN other news, WTF? You lose 1,716 hit points from a carniverous moxie weed? Was that slime damage?

Yes, it was slime damage. I had done 4 adv in the slimetube prior to the counter checker and the automatic mafia recovery running. Here is the log beginning with the 4th adv:

> Expected Damage: 260

[28846] The Slime Tube
Encounter: squirming Slime polyp
Round 0: [name here] wins initiative!
Round 1: [name here] tries to steal an item! (auto-attack)
You lose 260 hit points
You acquire an item: slimy fermented bile bladder
You lose 18 hit points
> Checking for updates (running CounterChecker ver. 1.27)...
> You have a current version of CounterChecker.
> Checking counters now.

clan_hobopolis.php?place=8&pwd

[28847] Rest in Clan Sofa (3 turns)
You gain 434 hit points

[28850] Menagerie 2
Encounter: Carnivorous Moxie Weed
Round 0: [name here] wins initiative!
Round 1: [name here] tries to steal an item! (auto-attack)
You lose 1,716 hit points
You acquire an item: moxie weed
> Oops, that wasn't the right number!

What is also bizarre about this character is that it completed the leaflet quest without learning CLEESH! I have not figured out how to go back and learn it. So this one can only go so far before ascension is needed to progress in the slimetube.

Raven434
02-10-2010, 01:56 PM
The script now uses the new eatsilent command to eat fortune cookies without interrupting your automation.

Huzzah!

Thanks Bale!

zarqon
02-12-2010, 05:03 AM
tgetgel brings up a good point -- UR should consider whether any counters are expiring before using recovery options that consume adventures. Mafia may handle that and fire this script appropriately, but as the above example shows, it may not.

Bale
02-12-2010, 05:11 AM
I suppose that could be considered an UR bug, though I think anyone who uses adventures to rest to be in a place I have trouble seeing. Anyway, if I was to modify UR to check for that do you know a way to trigger mafia's counter behavior? A counter script takes two parameters so I couldn't trigger it with a cli_excute'd call command.

zarqon
02-12-2010, 06:12 AM
Is UR visiting sofa/campground using visit_url()? I'm pretty sure if you used a CLI command or called adventure(), mafia would intercept it and run the counterScript, whereas simply calling visit_url() would probably circumvent the counterScript. Just guessing, could be wrong.

Bale
02-12-2010, 06:30 AM
That's a nice theory. However, tgetgel said he was not using UR. If mafia won't check for counters while resting from its default recovery I doubt it would work if UR called the sofa CLI command.

Perhaps this should be reported as a mafia bug.

zarqon
02-12-2010, 06:42 AM
So UR handles this situation fine then? I made the post after searching UR for the string "counter" and getting no matches. It could be a non-issue depending on how UR calls those recovery methods; I just wanted to bring it to your attention in case UR might also have this problem. I like scripts that consider all possibilities.

Bale
02-12-2010, 07:03 AM
I doubt that UR will handle the situation any better than mafia's default recovery. I was pointing out that since mafia's default recovery caused him to skip a counter I doubt that the sofa command will be any different.

I'm not sure how to make UR handle this better than that.

zarqon
02-12-2010, 07:07 AM
Depends how mafia handles it. If calling "sofa" or "rest" ignores counters (which would be a bug, but this is not necessarily the same as mafia's auto-restore), UR should consider those options unavailable for restoring if there are expiring counters within the number of times you'd be sleeping/resting.

Bale
02-12-2010, 07:09 AM
Anyway, as a result of this I switched UR's usage of sofa from visit_url() to the cli command sofa. I just doubt it will make a difference. Maybe that will be better than mafia's auto-restore.

Actually, his problem is worse than that since the counter expired and the counterScript was called. Then it spent adventures to rest on the sofa before getting the semi-rare. This means there is no longer a counter at turn 0 to check for. That really sucks.

slyz
02-12-2010, 11:15 AM
Well, counterchecker at least knows he shouldn't be spending turns anywhere, so maybe it could uncheck the sofa and the campground as restoration options before trying to adventure ? Or at least check if they are in the hpAutoRecoveryItems preference, and abort if if needed ?

Bale
02-12-2010, 05:11 PM
Ugh. To "uncheck" those options it would have to search hpAutoRecoveryItems, remove them from the string of options, then append them back after getting the semi-rare. (Actually I'm not sure if their order in the string is significant.) That's assuming that he has eaten more than 1 cookie so it won't be a false alarm and he actually needs the healing to survive there.

So far I feel that people who are willing to spend adventures resting should just understand that the sudden loss of adventures can screw up anything time sensitive. Don't do it if you want to automate semi-rares, absinthe, dance cards, etc...

zarqon
02-16-2010, 04:13 AM
Bale, just wanted to say -- I made the switch a while back to using this script. I use something else for wormwooding, so I commented out the wormwood stuff, but the other comprehensive counter coverage is excellent and useful. Thanks!

Bale
02-16-2010, 05:12 AM
Sometime I'd like to see what you prefer to use for wormwooding. If yours is better than mine I might be able to include it.

zarqon
02-16-2010, 05:29 AM
I prefer it because it's keyed to my playstyle, so I don't know that it would be inclusible for broader uses. But the nice thing about it is that if the goal (!pipes) gets compromised (say, by a holiday monster), it will adapt and get stats. I could send it to you if you'd like a look -- it looks like the algorithm is basically the same. I also did a switch on the number of Absinthe-Minded remaining!

EDIT: Here are the contents of my getpipes.ash. Doesn't look like there's much that you could use, since this is hardcoded specifically for pipes and moxie and is built for turn-burning. You may be able to do something to make your script adapt to interrupts for all goals that require effects though.

getpipes.ash



// getpipes -- specifically gets not-a-pipes, more robustly than previously
// gets moxie in the event that something interferes with your pipe-getting
// by default, gets enough to fill your spleen; otherwise, gets specified num

import <zlib.ash>

boolean single_pipe(location where) {
boolean intact = true;
if (my_adventures() < 10) return vprint("You need a minimum of 10 adventures.",-2);
cli_execute("conditions clear");
switch(have_effect($effect[absinthe-minded])) {
case 0: if (have_effect($effect[Absinthe-Minded]) == 0) {
if (item_amount($item[tiny bottle of absinthe]) == 0) buy(1,$item[tiny bottle of absinthe]);
use(1,$item[tiny bottle of absinthe]);
}
if (have_effect($effect[Absinthe-Minded]) == 0) return vprint("Unable to use absinthe.",-2);
case 10: adventure(1,where);
case 9:
case 8:
case 7: while (have_effect($effect[Absinthe-Minded]) > 6 && have_effect($effect[Spirit of Alph]) == 0)
adventure(1,$location[Stately Pleasure Dome]);
if (have_effect($effect[Spirit of Alph]) == 0)
intact = vprint("Something prevented your being imbued with the essence of Alph. Getting moxie instead...",-3);
case 6: adventure(have_effect($effect[Absinthe-Minded])-5,where);
case 5:
case 4:
case 3: set_property("choiceAdventure168",to_string(1+to_int(intact)));
if (intact) {
while (have_effect($effect[Absinthe-Minded]) > 2 && have_effect($effect[Feelin Philosophical]) == 0)
adventure(1,$location[Mouldering Mansion]);
if (have_effect($effect[Feelin Philosophical]) == 0)
intact = vprint("Something hindered your approaching of the Cat. Getting moxie instead...",-3);
} else {
cli_execute("conditions clear; conditions add 1 choiceadv");
if (adventure(have_effect($effect[Absinthe-Minded])-1,$location[Mouldering Mansion]))
vprint("Something hindered your getting the proper choice. Phooey. At least you can get a bit of moxie.",-3);
}
case 2: adventure(have_effect($effect[Absinthe-Minded])-1,where);
case 1: if (intact) adventure(1,$location[Rogue Windmill]);
else {
set_property("choiceAdventure166","2");
adventure(1,$location[Stately Pleasure Dome]);
}
}
if (intact && item_amount($item[not-a-pipe]) > 0 && my_spleen_use() < spleen_limit() - 3) use(1,$item[not-a-pipe]);
return intact;
}

void main(int howmany,location where) {
if (howmany < 1) {
while (floor((spleen_limit()-my_spleen_use()) / 4) > 0) single_pipe(where);
} else for i from 1 to howmany
single_pipe(where);
}

Bale
02-16-2010, 09:08 AM
True that there isn't anything I can use directly, but there is still some interesting code there. It's surprisingly flexible despite being single-minded. It's interesting to think about adapting that concept.

smeaty todd
03-15-2010, 04:15 AM
I'm a pretty casual mafia user, so I wasn't really able to figure this out from the code itself/don't want to test it empirically -

I know it's set up to allow the user to determine if they want to get the most expensive SR while in HC,
but if they don't, what happens? Does it halt auto-adventuring? or simply keep on auto-adventuring? [If the latter, how do I change it to abort instead?]

Also, having just done a cloverless run, is there any way to halt production of food/booze if the number of turns required would cause one to miss their SR? Or keep you from using the shore...

Anyway, I know it's hardly your domain, but some hard-coded counter on the left-hand panel of the Mafia window for SRs would be nice. For SRS.

adeyke
03-15-2010, 04:28 AM
It will abort when the counter hits 0 and it'll give you the location of the previous semi-rare as CLI output.

Bale
03-15-2010, 05:16 AM
I know it's set up to allow the user to determine if they want to get the most expensive SR while in HC,
but if they don't, what happens? Does it halt auto-adventuring? or simply keep on auto-adventuring? [If the latter, how do I change it to abort instead?]

Also, having just done a cloverless run, is there any way to halt production of food/booze if the number of turns required would cause one to miss their SR? Or keep you from using the shore...If you set it to not get semi-rares in HC, then it will stop adventuring when your semi-rare comes up and display the location of your last semi-rare in the CLI. Some people like this script just for that function since it saves them the trouble of typing "counters" when they need to decide what semi-rare to get.

If turns spent cooking/mixing/smithing will take you past a counter, mafia will trigger the counter and warn you instead of doing it. Then if you tell mafia to do it again, it will ignore the counter.

Atreyuu
03-20-2010, 05:24 PM
Until the first time it runs, variables won't be put into your vars file. If you want to add those variables so that you can edit them easily (before your counter comes up), you can run the program from the menu. It will ask you for a string and an int. The answers aren't very important as long as you input nonsense that it doesn't know how to deal with.

Step-by-step:

In the program menu: Scripts -> CounterChecker.ash
Please input a value for string name: HI
Please input a value for int remain: 33
Edit vars_coolbufferbot.txt


But when I go to my

I must be doing something wrong, I do steps 1-3 and get:


> call scripts\CounterChecker.ash

Checking counters now.
In 33 turns it will be time to do something when your HI counter is up.
You'll need to kill some time until then since the current action requires more than 1 turn


So then I go to my Data folder and find vars_Atreyuu.txt and open it up. There is no entry for "BaleCC_ImprovePoolSkills".

I'm using CounterChecker v1.27
I'm sure it's an error on my end but I don't really know what to look for.

Bale
03-20-2010, 06:41 PM
I have no idea. Fortunately there is more than one way to skin a catfish. Just type in the CLI:


zlib BaleCC_ImprovePoolSkills = true

And that should set the variable.

Atreyuu
03-20-2010, 07:22 PM
> zlib BaleCC_ImprovePoolSkills = true

No setting named 'BaleCC_ImprovePoolSkills' exists.

Maybe I should delete my vars_Atreyuu file? Doesn't appear to be much in there that I can't easily fix in 10 minutes or so.

Edit: Ok, so rather than wait for a response I deleted my vars file. It rebuilt like I figured it would. It now accepts


zlib BaleCC_ImprovePoolSkills = true

in the CLI but still no entry in the vars file. My turns for the day are used up so I can't test it but it as the CLI didn't send me an error I'm assuming it's working? I don't know.

zarqon
03-22-2010, 03:05 AM
I've also noticed that the CounterChecker settings are not in my vars file. This may be a mafia bug -- previously, map keys that pointed to empty strings were not being loaded properly by file_to_map(). Since the vars are not actually in the map, you may want to see what happens if you change the default value (in the script, where it calls setvar()) to true. This may allow you to get the setting properly in the map. Also, it may reveal whether or not this is a mafia bug.

CunningGabe
04-03-2010, 06:38 PM
Just downloaded this script yesterday and started using it. It's great, though I have one suggestion: distilled fortified wines should be one of the choices. Since you get 3 at a time, that semi-rare adventure is worth about 18K meat at current mall prices.

slyz
04-04-2010, 06:23 PM
I added distilled fortified wine, tasty tarts and scented massage oils to the semi-rares to be checked.

Bale
04-04-2010, 06:26 PM
Yeah, I'll add that to my version when I have some time.

slyz
04-20-2010, 11:10 AM
I only now tried to use the dance card feature, and it turned out I don't have either BaleCC_SrInHC, BaleCC_useDanceCards or BaleCC_ImprovePoolSkills in my vars file.

You should move lines 409-412 where setvar() is used for those to line 40, before checking for the settings in the vars map.

Bale
04-20-2010, 11:42 PM
OH! Good point. I'll post an update right now including that as well as your recent fixes for distilled fortified wine, tasty tarts and scented massage oils. Thanks.

Note: requires latest version of zlib (http://kolmafia.us/showthread.php?t=2072) because of a new, but rather minor feature. (Reports current sale price of the semi-rare that it choses.)

Banana Lord
05-09-2010, 04:45 AM
Why did it take me so long to find this script?! Awesome work as always Bale!

Bale
05-09-2010, 05:27 AM
Glad it's helpful to you.


Why did it take me so long to find this script?!

No clue. There's a complete list of my published scripts here (http://zachbardon.com/mafiatools/details.php?a=bale). Maybe one of those will full another need of yours. :)

Banana Lord
05-09-2010, 06:09 AM
Haha, thanks! I'll have a look over that. On another note, wow, Zarqon's really been busy!

Oh and I'm not entirely sure of how the steel organ part works, does it only adventure at the Gate once all of Azazel's items've been found? Does it do the pencil-necked demon trick?

Bale
05-09-2010, 06:33 AM
Oh and I'm not entirely sure of how the steel organ part works, does it only adventure at the Gate once all of Azazel's items've been found? Does it do the pencil-necked demon trick?

Well, if you have a counter set (you probably do not unless you add it yourself or have it in your between battle script like I do), then it will just stop automation and tell you about it. It does nothing automatically regarding that.

suinoq
06-09-2010, 04:44 AM
Just came across this script, so forgive me if this feedback isn't on point. I've only just starting dabbling my delicate little toesies in the scripting pond. Anyhow:

1. Jar of Squeeze doesn't seem to be included in the set of SRs to check prices on.

2. Also, I like to drink Milk before eating cookies.

3. Sometimes I purposefully delay eating my cookie until the next semirare window is upon me, and then decide whether or not the cookie will be necessary. Usually I do this when messing around in Hobopolis, if I know that I'll be adventuring in either the PLD or BB for the entirety of (or at least the beginning of) the upcoming SR window.

Bale
06-09-2010, 04:56 AM
1. Good point. Perhaps I should add it.

2. Well, I suppose 1000 meat is not necessarily too much to spend for 1 adventure. I could add that as a preference.

3. I could also add automatic cookie eating as a preference for you to turn off. Is that what you want?

suinoq
06-12-2010, 05:40 PM
1&2. Yay!

3. I'm having difficulty seeing the best way forward for this issue. The power of the script, to me at least, is that it permits auto-adventuring without having to stop and deal with counters along the way. No mucking around with the details, no need to think too hard.

On the other hand, when I'm skipping cookies it requires me to make small, detailed, tactical decisions to eke out a few more adventures from my stomach. It would seem tough to script, but I'll attempt it:

Algo:
Don't eat cookie. Adventure until the SR window begins.
While SR hasn't been found

If next turn would be in a zone with a 'valuable' SR**

Execute turnElse

Eat cookie
End

Ok, that ended up being pretty simple. There's some trickery with the line of logic with the **, however. If the zone in question has, say, the third most valuable SR available then I'm weighing whether spending 1 fullness on a cookie is worth the upgrade to a better SR. This decision isn't one that seems reasonable to script.

zarqon
06-13-2010, 05:04 AM
I like this a great deal, but perhaps the feature is being requested in the wrong script. Most of the change in functionality would need to go in a between battle script, since the decision may change when your location changes, but no counter will fire when this happens. I would be happy to add the necessary lines to BBB, if Bale and I can work out how the scripts would be made to work both together and independently.

The change in logic would only require adding a single setting. Basically, if you save yourself a fullness point by not eating a cookie, you are earning yourself at least one more adventure, probably more, so the valueOfAdventure preference could be used here. If the current location has a semirare worth at least optimalsemirare - valueOfAdventure*X, it's worth it from a turncount standpoint, if not a monetary one. I'd recommend making X the setting (number of turns a fullness point is worth to you), that way setting it to 0 would basically disable it.

Changes to CounterChecker:

If Fortune Cookie counters are known, it will always attempt to get the most valuable semirare possible (current behavior). However, it would NOT attempt to eat a cookie afterward. No additional handling for window counters needs to be added here.

Changes to BBB:

If no cookie counters exist (including window counters), eat a cookie.
If the window begin counter is < 1 and a window end counter exists, decide whether or not to eat a cookie based on whether the current location's semirare is worth at least X*valueOfAdventure less than the optimal semirare. If so, don't eat a cookie.
Respect CounterChecker's srInHC preference.

This would result in optimal stomach usage as described by suinoq.

Bale
06-13-2010, 07:04 AM
That would be fairly simple coordination. A single option in vars to indicate that a cookie is not to always be automatically eaten. Then BBB can kick in to decide about eating a cookie under those circumstances.

zarqon
06-13-2010, 07:17 AM
Why don't we double up the functionality of the setting. It will be an integer indicating the number of turns a fullness point is worth for eating cookies. If 0, CC will eat cookies, otherwise it will leave the decision to BBB.

I'll need to figure out how to figure out the optimal semirare, so I might be importing CC into BBB, depending (haven't investigated yet). Does conditional importing work? I'm suspecting not.

Bale
06-13-2010, 08:59 AM
I can't see why importing wouldn't work. Unfortunately while that will tell you the optimal semi-rare location, it won't allow you to rate semi-rares to figure out the value of the current location. I could modify the script to be friendlier to that way of doing things so that I'd have a function returning a map of prices indexed by location. Would that be better for you?

zarqon
06-14-2010, 06:01 AM
Importing would work, of course. I was wondering about conditional importing. Think I've tried it before without success, but there used to be an example in the ASH wiki that imported different scripts depending on my_name(). Just wondering if I could check the cookieturns setting before taking up resources by importing.

I'm pretty sure it wouldn't work since it means there may or may not be certain functions defined in the BBB's namespace.

Bale
06-14-2010, 08:10 AM
I'm pretty sure it wouldn't work since it means there may or may not be certain functions defined in the BBB's namespace.
That seems pretty likely.

Yepa
08-20-2010, 04:04 PM
Stupid n00b question: Just installed this. Am I right to assume that it'll start tracking my semi-rares when I eat a fortune cookie? and I'll do that after each semi-rare? A bit unsure about how this works and since I'm new to kolmafia I figured i'd better ask.

Also, where do I find the counter? in the CLI? (I'm not planning to adventure with mafia, just using it to track stuff like this)

ETA: I'm doing hardcore runs, by the way.

Theraze
08-20-2010, 04:08 PM
Just verifying... you did do the
set counterScript = CounterChecker.ashalready? Also, you have to configure it to automatically do SR if you want it to do that while HC. He has that in the second post...
•BaleCC_SrInHC: Automate Semi-rares in Hardcore and Ronin. If this is false, then you won't have to worry about CounterChecker determining your semi-rares for you while ascending.

Yepa
08-20-2010, 04:12 PM
I did set counterscript, so it's functional. I don't want my Semi-rares automated, I just want somewhere to check the counter so I can decide where to do my Semi-Rares myself. Not sure how to do that.

ETA: I've just downloaded KOlmafia today, so there might be something really obvious that I'm missing.

heeheehee
08-20-2010, 04:15 PM
If you're using the Relay Browser, it'll show up in the charpane. If you want to check it in the CLI for whatever reason, just enter "counters" (no quotes, of course).

Yepa
08-20-2010, 04:25 PM
Thanks. I've no idea what the charpane is, or where it is (character panel, or something maybe?).. ehm, so, yes, that's how bad I am with this stuff. But the counters command works!

Winterbay
08-20-2010, 04:30 PM
Thanks. I've no idea what the charpane is, or where it is (character panel, or something maybe?).. ehm, so, yes, that's how bad I am with this stuff. But the counters command works!

Charpane = the thing with your stats and so on to the left of your KoL screen.

Yepa
08-20-2010, 04:35 PM
Hmm.. It's not showing up there for me... Feel like a right idiot, but there you go. Maybe it'll show up tomorrow (since I just installed it today). Thanks though!

slyz
08-20-2010, 04:56 PM
Mafia already tracks your semirares, you don't need to install this script if you don't want to automate them. Of course, Mafia doesn't automagically knows your semi-rare number: it only saves the numbers you get when you eat a fortune cookie.

It also remembers when your last semi-rare was, if you got it when using Mafia, so it knows the window of your next semi-rare and can automatically discard numbers that are out of range.

The counters appear with your buffs in the Relay Browser's charpane, or when you type counters in the gCLI.

If you were already tracking a semi-rare, you can add a custom counter by typing counters add <number of turns left> in the gCLI.

If you are new to Mafia, I suggest you read SingingSally's guide (http://wiki.kolmafia.us/index.php?title=KoLmafia_Guide).

Camber
08-20-2010, 04:59 PM
Char pane is in the relay browser.

Perhaps you should view the kolMafia wiki? Its the 4th tab on this forum...
Check out SinginSally's guide in the New User section...

Ninja'd brillantly by slyz!

And SinginSally's Basics (Relay Browser) page fills in all the semi-rare counter details if you have any more questions.

Yepa
08-20-2010, 05:33 PM
Thank you to both of you. i'll check out the guide before asking any more obvious questions :)

zarqon
09-28-2010, 03:08 PM
Bale, writing an update to BBB and wanted to implement the cookie-eating thing we talked about before. So let's talk script synergy.

Here's what I have for starters:


boolean cookiecheck() {
if (!to_boolean(vars["auto_semirare"]) || my_fullness() == fullness_limit()) return true;
if (get_counters("Fortune Cookie",0,200) != "" || get_counters("Semirare window begin",1,200) != "")
return vprint("BBB: No need to eat a cookie given the present counters.","#F87217",8);
if (my_location() != to_location(get_property("semirareLocation")) && $locations[Purple Light District, Haunted Billiards Room,
Menagerie 2, Outskirts of The Knob, Limerick Dungeon, Sleazy Back Alley, Haunted Pantry, Harem] contains my_location())
return vprint("BBB: "+my_location()+" contains an acceptable semirare; not auto-eating cookie. Eat one manually if you want your counterScript to handle it.","#F87217",5);
return eatsilent(1,$item[fortune cookie]);
}

I'll probably expand the "acceptable semirare" detection to actually consider values later.

This is quite independent. The only issue now is that CC should refrain from eating cookies if BBB is set to do it. I think it would be nice if these two scripts could play nicely together, using a minimum of ZLib settings. CC doesn't really need to pass any information to BBB, but CC somehow needs to know whether BBB's smarter cookie eating is in effect.

I like the idea of sharing a vars[auto_semirare] setting. If false, neither CC nor BBB would eat cookies. If true, CC would only eat a cookie if !contains_text(get_property("betweenBattleScript"),"BestBetweenBattle").

Bale
09-28-2010, 09:42 PM
It is a worthwhile idea. The first problem I see is if the user renames BestBetweenBattle or he edits a personal version with a different name (I do this). That'd queer the deal.

Perhaps it should be just as simple as not eating a cookie if you have counters. That way, if my script eats a cookie, yours won't. Am I missing a reason that would not work?

zarqon
09-29-2010, 12:14 AM
That is already the case. The problem is how to get your script to avoid eating cookies if mine will later, since delaying is more optimal (as described by suinoc previously).

Bale
09-29-2010, 12:31 AM
Ah. Now I understand.

Because I want it to work even if BBB is not the name of the script, we need a different vector. Perhaps if BBB notices get_counters("Fortune Cookie",0,1) != "" || get_counters("Semirare window begin",0,1) != "", it can set var["LetMeEatIt"] = true and then CC won't do the eating.

tgetgel
09-29-2010, 03:36 AM
Perhaps it should be just as simple as not eating a cookie if you have counters.
My question is eating a fortune cookie when there are more than one counter or no counter and not eating another fortune cookie if there is only one counter.
What property do I need to use to detect the number of fortune cookie counters running? I would use this in an if statement - if not only 1 active counter, eat a cookie.

Bale
09-29-2010, 04:55 AM
get_counters("Fortune Cookie",0,200) will produce a tab delimited list. So, count the number of tabs? Hmmm... I guess something like this:


if(get_counters("Fortune Cookie",0,200) == "" || count(split_string( get_counters("Fortune Cookie",0,200), "\t")) != 1)
eatsilent(1, $item[fortune cookie]);

That's actually the first time I've ever thought split_string() (http://wiki.kolmafia.us/index.php?title=Split_string)was the easiest and best way to do something!

Incidentally, count(split_string( get_counters("Fortune Cookie",0,200), "\t")) is 1 if there are no current counters. That's why I needed the first check.

zarqon
09-29-2010, 06:34 AM
So our scripts will occupy 2 mafia properties and 3 ZLib settings, just to eat cookies? Seems a bit overkill. I'm trying to think of how to minimize the overhead.

Overloading variables is my favorite way to do this. Since ZLib settings are all strings anyway, let's pack the auto_semirare setting.

Possible values:
"true", "always" (means you always want a Fortune Cookie counter; CC would always eat cookies and BBB would if CC isn't installed)
"smart" (means you want to delay the smart way and you have appropriate handling in a betweenBattle script or mood; CC would never eat cookies and leave it to BBB/mood/etc)
"never", "off", "false" (neither script would eat cookies)

For any of the cookie-eating values, appending the word "single" would mean that CC or BBB would eat enough cookies to reduce you to only one active Fortune Cookie counter.

How's this sound?

Bale
09-29-2010, 07:29 AM
That idea sounds quite good to me!

One gripe: "smart" auto_semirare sounds like we're being smart about getting the semi-rare which obviously we are. That value's meaning is a bit counter-intuitive, so how about: "smarteat" or "delayeating" or "delaycookie" or something like that?

Also, I'd recommend that we avoid assigning values of "true" or "false" by default since the current zlib editors will produce a checkbox instead of a text field, making that harder to change to "smart".

Winterbay
09-29-2010, 07:42 AM
I'd say that "always" and "never" are probably the most intuitive values for those two settings, at least to me.

zarqon
09-29-2010, 11:57 AM
I included "true" and "false" (and "off" for that matter) as a sort of catchall -- our scripts should have handling for these values in case a user erroneously assumed the setting was a boolean. User documentation for adjusting the setting, however, would not include those as possible values -- just "always", "smart" (which we could change to "bide", "delay", or even "prevaricate" if it suits everyone better), and "never".

In practice, the scripts should probably treat all strings which are not recognized for eating cookies as "never", so the actual contents of the string don't really matter for that particular option.

Anyway, cool. I'll add this support to the upcoming BBB as soon as we decide what the optimal option should be called. Perhaps "optimal". I'm cool with whatever as long as it's one word. Perhaps "eventual" is better, consistent with the adverbial nature of the other options.

Winterbay
09-29-2010, 12:16 PM
I vote for "prevaricate", not that I have anything to say about it. I just love the word :)

zarqon
09-29-2010, 04:06 PM
"timely"!!! I like that one best.

Also, thought of an improvement. Rather than appending "single" let's append a number to the cookie-eating options. That number will be the desired number of cookie counters. So "1" would keep eating cookies until only one counter exists, "2" would keep eating cookies until two or fewer counters remain (which would more likely mean that it would just not eat a second cookie if one of the three lucky numbers is discarded). Default (nothing specified) would be to eat only one cookie, and not care about how many counters result.

Bale
09-29-2010, 09:51 PM
viable Options:
timely
true, always
false, never

Optionally there can be a number appended at the end to indicate maximum number of counters lest another cookie be eaten.

By appended, do you mean "timely 1" or "timely1"?

zarqon
09-29-2010, 11:46 PM
Excellent!

For appending, I was planning to use contains_text() so the space won't matter. Less opportunity for user error.

tgetgel
09-30-2010, 04:00 AM
get_counters("Fortune Cookie",0,200) will produce a tab delimited list. So, count the number of tabs? Hmmm... I guess something like this:


if(get_counters("Fortune Cookie",0,200) == "" || count(split_string( get_counters("Fortune Cookie",0,200), "\t")) != 1)
eatsilent(1, $item[fortune cookie]);
It worked perfectly. Thanks!

zarqon
10-12-2010, 12:50 PM
This is what I have now (untested):


boolean cookiecheck() {
if (my_fullness() == fullness_limit()) return true;
matcher cooks = create_matcher("([a-z]*) {0,1}([1-3]{0,1})",vars["auto_semirare"]);
if (!cooks.find()) return vprint("Warning: your auto_semirare setting is not an accepted value: timely|always|never (maximumcounters)",-5);
switch (cooks.group(1)) {
case "timely": if (get_counters("Fortune Cookie",0,200) != "" || get_counters("Semirare window begin",1,200) != "")
return vprint("BBB: No need to eat a cookie given the present counters.","#F87217",8);
if (my_location() != to_location(get_property("semirareLocation")) && $locations[Purple Light District, Haunted Billiards Room,
Menagerie 2, Outskirts of The Knob, Limerick Dungeon, Sleazy Back Alley, Haunted Pantry, Harem] contains my_location())
return vprint("BBB: "+my_location()+" contains a nice semi-rare; not auto-eating cookie. Eat one manually if you want your counterScript to handle it.","#F87217",5);
case "always": case "true":
while (get_counters("Fortune Cookie",0,200) == "" ||
(to_int(cooks.group(2)) > 0 && count(split_string(get_counters("Fortune Cookie",0,200),"\t")) > to_int(cooks.group(2)))) {
if (my_fullness() == fullness_limit()) return true;
if (!eatsilent(1,$item[fortune cookie])) return false;
}
}
return true;
}

I would like to point out that I have realized the truth of these immortal words: "Fear leads to anger. Anger leads to hate. Hate leads to suffering." Therefore, I have faced my fears and included my first ever regex. If I did something suboptimally, please let me know.

This will be in the upcoming BBB update, just as soon as I figure out how to update the auto-turtle-taming given recent changes. Blasted TPTB, I really can't keep up with all their changes these days.

xKiv
10-12-2010, 02:35 PM
{0,1} is usually written as ?
You also probably want [a-z]+ instead of [a-z]*, so that it doesn't match empty strings.
That makes


matcher cooks = create_matcher("([a-z]+) ?([1-3]?)",vars["auto_semirare"]);


Of course, since you only have three valid values for the first group anyway, you might want to actually ensure that ... (your version doesn't catch this condition anywhere, not even in the switch):



matcher cooks = create_matcher("(timely|always|never) ?([1-3]?)",vars["auto_semirare"]);

zarqon
10-13-2010, 03:05 AM
Oh yeah, I'd changed that * to a + locally but I guess I'd pasted it here before changing that.

Excellent about the ?, I hadn't come across that in the tutorial I read.

And there are more than three valid values, but only three of them matter to the code (and that doesn't include "never" since all non-matches are treated as "never"). So I'll either include all possible values in the group in the manner you suggest or just keep matching on any word.

xKiv
10-13-2010, 03:24 PM
I would probably just keep the pattern matching anything, then add a catch-all default: in the switch to display the error message (and put that message somewhere else, so that you don't have to fix two occurences of the same string when you change the valid values). Just so I wouldn't have to *triplicate* the list of valid values (once in the switch, once in the error message, once in the regex).

ETA: or, if you want to treat all non-matches as "never", you might want to write a comment to that effect (the several-years-down-the-timeline-you will than the now-you for that practice) and possibly modify the warning?

zarqon
10-14-2010, 05:17 AM
Ended up going with "(timely|always|true|never|false) ?([1-3]?)". Thanks for your help.

@Bale: new BBB will be rolled out within a day or two. Feel free to snatch any of the posted code for eating/parsing the preference to make our scripts play wonderfully together.

Also -- would you prefer "auto_semirare" or "bbb_auto_semirare"? The former follows my ideals for shared names, but several users seem to prefer that every setting be prefixed with an owning script even when multiple scripts reference it. I'll leave that call up to you (and whoever else chimes in here).

Theraze
10-14-2010, 05:33 AM
Would it make sense for multi_auto_semirare, multiple_auto_semirare, or shared_auto_semirare? Something that's obviously shared, but splits it off as well.

Bale
10-14-2010, 10:24 PM
@Bale: new BBB will be rolled out within a day or two. Feel free to snatch any of the posted code for eating/parsing the preference to make our scripts play wonderfully together.

I've been busy with other things. I'll try to get to this soon.

Basically, I just need to skip eating cookies when the value of vars["auto_semirare"] is timely, never or false. (Or if numerical, eat another cookie when I have more than that number of cookie counters.) Right?

zarqon
10-15-2010, 03:47 AM
Basically, yes. Your script should react as follows to the "auto_semirare" setting:

"always (n)" or "true": definitely eat enough cookies to guarantee no more than n Fortune Cookie counters (or any counters if not specified). Some of the above code is probably directly stealable for this. You could adjust the matcher to "(always|true) ?([1-3]?)" and if no matches are found, skip eating cookies.
anything else: skip eating cookies.

slyz
10-15-2010, 04:00 AM
When you don't have a semi-rare window set, Mafia doesn't always discard numbers that are too high. This should only be a problem for the first Semi-rare of a run though. Maybe this should be taken into account before eating 2 cookies to discard a number that should have been discarded but wasn't?

zarqon
10-15-2010, 05:01 AM
Using a reasonable maximum number in get_counters() should obviate that problem.

Bale: this is not pressure, just information. Take your time. BBB will work fine without CC being updated. It will just work better after the CC update. Script synergy ftw.

Bale
10-16-2010, 09:31 PM
So, what do you think of this?


int count_counters() {
string counters = get_counters("Fortune Cookie", 0, 200);
if(counters == "") return 0;
return count(split_string(counters, "/t"));
}

boolean toEat() {
if(vars contains "auto_semirare") {
matcher cooks = create_matcher("(timely|always|true|never|false) ?([1-3]?)", vars["auto_semirare"]);
if(cooks.find())
switch(cooks.group(1)) {
case "false":
case "never":
case "timely": return false;
case "always":
case "true": return count_counters() < cooks.group(2).to_int();
}
}
return count_counters() < 1;
}


void eat_cookie() {
if(get_property("semirareCounter").to_int() != last) {
// semi-rare acquired, let's do it again
if(my_fullness() == fullness_limit())
print("If I ate even a fortune cookie I'd burst! Remember to eat a fortune cookie when the tummy is emptier.", "red");
else while(toEat())
eatsilent(1, $item[fortune cookie]);
} else
print("Oops, that wasn't the right number!", "red");
}

zarqon
10-18-2010, 06:29 AM
That should work just dandily. Looks like I'll be spinning a BBB update today! w00t

Kenshiro70
10-18-2010, 06:50 PM
I love the integration between the two scripts. One request: for aftercore farming, is there any way that I can specify whether to use milk of magnesium before eating the cookie? Thanks so much!

adeyke
10-18-2010, 08:02 PM
The milk will add exactly one adventure, so you'd just have to compare the price of the milk to valueOfAdventure to see if it would be worth it.

Bale
10-18-2010, 10:33 PM
The milk will add exactly one adventure, so you'd just have to compare the price of the milk to valueOfAdventure to see if it would be worth it.

I agree that makes sense. However, if I added the feature I think a simple "true" or "false" to using milk would be best since otherwise I'd get complaints.

zarqon
10-19-2010, 05:21 AM
You'll get complaints no matter what, so that's not particularly relevant. :)

I like comparing it to valueOfAdventure, particularly if you may be about to eat multiple cookies and thereby gain multiple adventures (for example, if someone specified "always 1"). Depending on prices, that may mean the difference between profit and loss.

Seems to me like calculating the odds of getting X valid counters from Y cookies is necessary -- solving for Y (as a float). That number would be multiplied by valueOfAdventure to determine the gross profit of eating milk. But that's what I might call overkill.

EDIT: This problem interested me so I came up with this:


int valid_sr_count() {
if (get_counters("Fortune Cookie",0,200) != "")
return count(split_string(get_counters("Fortune Cookie",0,200),"\t"));
int counter_num(string whichcounter) { // returns the first matching counter, or -1 if not found
if (get_counters(whichcounter,0,2000) == "") return -1;
for i from 0 to 2000 if (get_counters(whichcounter,i,i) != "")) return i; return -1;
}
int sr_start() {
return max(0,max(counter_num("Semirare window begin"),70 - my_turncount()));
}
int sr_stop() {
if (get_counters("Semirare window end",1,200) != "") return counter_num("Semirare window end");
if (my_turncount() < 82) return 81 - my_turncount();
return 200 - (to_int(in_hardcore() && !can_drink() && !can_eat()))*80;
}
return sr_stop() - sr_start();
}

// chance that a random lucky number will be valid
valid_sr_count()/300

// chance that a random lucky number will be discarded
1 - (valid_sr_count())/300)

// counters after eating one cookie
1 + 2*(valid_sr_count()/300)

It may be useful. Or maybe not.

Glazius
10-20-2010, 06:04 PM
I have a quick question on usage. I've got this script set up and working properly to trigger counters, but I'm curious how to use it to help me do a specific thing.

I have an arbitrarily large supply of absinthe, but all I want to get is three not-a-pipes a day (generally a bounty with sniffing takes about this long). If I set a mood to reapply absinthe-minded I have to fiddle around by adventuring until I get two pipes, clearing the trigger, and getting the last pipe; otherwise, since conditions aren't checked until the last "real" adventure, not the counter interrupt, I end up swigging an extra bottle.

Is there some way to go about this other than simple effect triggers and mood setting, preferably one that requires less day-to-day intervention on my part, even if it's more complex to set up?

slyz
10-20-2010, 07:06 PM
You can do wonders with an ASH command in a mood. For example, create a Mafia setting that will be cleared every day to indicate that you have not farmed your !pipes yet:



Trigger On: When an effect is lost
Check For: Absinthe-Minded
Command: ashq int n=get_property("_pipesFarmed").to_int(); if(n<3){use(1,$item[tiny bottle of absinthe]);set_property("_pipesFarmed",to_string(n+1));}

(this is untested)

Glazius
10-21-2010, 04:32 PM
Yeah, that seems to work fine. Just need to reset that counter in my breakfast script and I'm golden. Thank you!

Camber
10-21-2010, 04:35 PM
Just need to reset that counter in my breakfast script and I'm golden.

No need, preferences/properties prefaced with an underscore are reset to zero each day.

Theraze
10-21-2010, 04:39 PM
Don't, actually. The _ before the preference name means that KoLmafia automatically resets it each day.

Edit: Ninja-ed while reading another post!

mredge73
10-22-2010, 04:07 PM
Not exactly each day.
It resets at each logout/login on mine.

Theraze
10-22-2010, 04:26 PM
EVERY logout/login, or just when it's a new day? Either way, it's probably a bug, though with the first it's a higher severity.

Theraze
10-24-2010, 04:58 PM
Still curious about if it's bugged/not clearing properly. Did have a new issue though... it appears that CC doesn't use CanAdv to check if you can actually go to the zone, or maybe the CanAdv check failed miserably. Got the following:
You have a current version of CounterChecker.
Checking counters now.
Getting a irradiated pet snacks which is currently selling in the mall for 15,500 meat.

You need 1 more turtle pheromones to continue.
Unable to acquire the effect 'Eau de Tortue'.

Visit to Lab: Menagerie 2 in progress...
You can't get to that area.

Bale
10-24-2010, 10:12 PM
I don't use canadv for this. You're right that I should add a check for the knob lab key. I'll have to take care of that later, when I have a little time.

Theraze
10-27-2010, 07:21 AM
Trying this to see if it works... hoping it does, as it appears to be the right code for things. :)

Added
import <canadv.ash>under the zlib import, and added
if (!can_adv(locale,false))
continue; into the foreach locale bit. So that whole section changes to this:
foreach locale, rare in semi_rare {
if (!can_adv(locale,false))
continue;
if(historical_age(rare) > 1 || historical_price(rare) == 0)
mall_price(rare);
if(semi_rare_multiplier contains rare)
rare_price = semi_rare_multiplier[rare] * historical_price(rare) ;
else rare_price = historical_price(rare) ;
if( rare_price > expensive) {
best = locale;
expensive = rare_price;
}
}

Hadn't gotten to actually try it, but just had my semirare trigger, and got the following:
Request 12 of 44 (Mountain: Barrel full of Barrels) in progress...
Checking for updates (running CounterChecker ver. 1.4)...
_version_BaleCC => 1.4
You have a current version of CounterChecker.
Checking counters now.
unlockedLocations => 5-- Haunted Billiards Room
Searching for "distilled fortified wine"...
Getting 3 bottles of distilled fortified wine which are currently selling in the mall for 5000 meat each.

Visit to Town: Sleazy Back Alley in progress...

[424] Sleazy Back Alley
Encounter: In the Still of the Alley
You acquire distilled fortified wine (3)

Should hopefully work fine out in general and not do anything weird. If I'm understanding properly, the 'false' on can_adv just means to not heal up as you're parsing through areas. I suppose since it's a semi-rare, you may actually want to heal up, but unless you actually hit the ultra-rare, I think they're all non-combats, so... doesn't really matter if you heal, right?

Anyways, I won't really know if it works until I hit a semi-rare right after ascension again, but hopefully this should reduce chaos for others. :)

zarqon
10-27-2010, 08:59 AM
Two small things:

1) You don't need to import both canadv and zlib -- canadv imports zlib, so you can just import canadv.
2) The second parameter (prep) should be true if you want to actually adventure somewhere afterwards, otherwise false. In other words, true means that it will prepare (equip gear or use items to get effects or open zones), whereas false means that it will only tell you whether adventuring there is possible. You correctly used false in the loop for eliminating impossible zones, but depending on whether or not any of the zones have necessary preparations, you may also want to call it again with prep true before actually adventuring there.

Theraze
10-27-2010, 01:44 PM
Useful. :) I suppose that the prepped version would be called in the get_semirare() function, immediately after the location locale = expensive_semi(last_rare); line. One question... is this a time to force a checkpoint before and restore it after the adventure is done? I don't want to screw up people (like me) whose adventuring might be more scattered and have requirements of its own.

Edit: Also, due to boredom, added in ALL the semi-rares... well, except the Filthy Crown. Made the Purple Light District check also remove the other Hobo zones. Did do the checkpoint before/outfit checkpoint after. Will see how well it works next semi-rare I get... :)

Edit2: Just got this on my level 8... Turtle Tamer, obviously. :D
Checking for updates (running CounterChecker ver. 1.4)...
_version_BaleCC => 1.4
You have a current version of CounterChecker.
Checking counters now.
unlockedLocations => 5-- Batrat and Ratbat Burrow
Checking resistance to stench...
Searching items for stench resistance...
Resistance-granting item found: Knob Goblin harem veil
unlockedLocations => 5-- Batrat and Ratbat Burrow Haunted Billiards Room
Searching for "cube of billiard chalk"...
unlockedLocations => 5-- Batrat and Ratbat Burrow Haunted Billiards Room Haunted Kitchen
Searching for "tasty tart"...
You gain 1,000 Meat
Getting a Knob Goblin lunchbox which is currently selling in the mall for 20,800 meat.
Internal checkpoint created.

Preparing to tame a knobby helmet turtle...

Visit to Knob: Outskirts of The Knob in progress...

[621] Outskirts of The Knob
Encounter: Lunchboxing
You acquire an item: Knob Goblin lunchbox
Edit3: And on a different level 8:
Checking for updates (running CounterChecker ver. 1.4)...
_version_BaleCC => 1.4
You have a current version of CounterChecker.
Checking counters now.
unlockedLocations => 5-- Batrat and Ratbat Burrow
Checking resistance to stench...
Searching items for stench resistance...
Resistance-granting item found: Knob Goblin harem veil
unlockedLocations => 5-- Batrat and Ratbat Burrow Haunted Billiards Room
Getting a Dogsgotnonoz pills which is currently selling in the mall for 17,400 meat.
Internal checkpoint created.

Visit to BatHole: Batrat and Ratbat Burrow in progress...

[820] Batrat and Ratbat Burrow
Encounter: How Does He Smell?
You acquire an item: Dogsgotnonoz pills

heeheehee
11-08-2010, 06:05 AM
Very minor feature request (I could probably fork this into my local version if you're unwilling, but I think others would benefit from this) -- can you add some code to check valueOfAdventure and use that (presumably in conjunction with autoSatisfyWithMall or something like that) to figure out whether munchies pill / milk of magnesium would be worth using before consuming a fortune cookie?

(notes: munchies pill adds 3 adv per cookie, milk adds 1 adv per cookie.)

Theraze
11-08-2010, 06:27 AM
Question... after pulling a semirare, don't you have to do another adventure following the acquisition to restart the counters? Or am I just too tired to think right now? My checks are running a bit odd currently, so, I figured I'd check if there was a good reason for it to hate me. :)

Also, would it be possible to have it check (possibly another variable) if there's a range of either exactly 40, or no counter at all? Since it reinitializes at a range of 40, that could be a check if you've acquired a semirare and not had it considered. It just really likes to trigger immediately before/after the semi-rare and force me to collect another after the session finishes.

Bale
11-08-2010, 08:55 AM
Very minor feature request (I could probably fork this into my local version if you're unwilling, but I think others would benefit from this) -- can you add some code to check valueOfAdventure and use that (presumably in conjunction with autoSatisfyWithMall or something like that) to figure out whether munchies pill / milk of magnesium would be worth using before consuming a fortune cookie?

(notes: munchies pill adds 3 adv per cookie, milk adds 1 adv per cookie.)

I'm not really interested in writing the code to add the feature, but if you write the code for it I'll probably add it into this script for the sake of all. Link it to a zlib variable since it will annoy some people and I want to leave it off by default.


Question... after pulling a semirare, don't you have to do another adventure following the acquisition to restart the counters? Or am I just too tired to think right now? My checks are running a bit odd currently, so, I figured I'd check if there was a good reason for it to hate me. :)

Getting the semi-rare hits adventure.php and restarts the counters. It's not an issue. For a while I was under the impression that the hidden city semi-rare wouldn't restart the counter since it doesn't hit adventure.php, but it turns out that the semi-rare redirects to adventure.php so it's good also.


Also, would it be possible to have it check (possibly another variable) if there's a range of either exactly 40, or no counter at all? Since it reinitializes at a range of 40, that could be a check if you've acquired a semirare and not had it considered. It just really likes to trigger immediately before/after the semi-rare and force me to collect another after the session finishes.

I'm afraid I have no idea what you're asking.

Theraze
11-08-2010, 01:26 PM
I'm afraid I have no idea what you're asking.

For some reason, it REALLY wants to run the eating of the cookie right before it does the adventuring, enough so that I actually completely removed the eatcookie function from my copy of CounterChecker. It may have to do with adding CanAdv to my copy, not sure.

What I was wondering is, if it's possible to have it check if the counter has been reset back to its range of 40... 159-199, 160-200, etc. As it does after actually finding the semi-rare.

The setup around how it was running was that it was set to timely (the default), using counterchecker as its counter script and zarqon's BBB as its between battle script. The behaviour was that it would start the CanAdv check (with prep as false), decide where to go, run CanAdv (with prep to true), eat a fortune cookie, THEN run the actual adventure. Because KoLmafia resets the cookie counter on semirare acquisition to 160-200, it would then decide that it didn't need to eat another cookie.

With the auto-recookie removed from CounterChecker and auto_semirare set to always, BBB still triggers eating a cookie BEFORE the semi-rare adventure, but will actually eat one the turn after as well. Not sure what's triggering the precookie-ing part. Guessing it's somehow tied into the new CanAdv checks though. On a positive note, using my copy of CanAdv that actually checks if the Knob is unlocked, haven't wasted a Semirare encounter since though...

heeheehee
11-08-2010, 02:55 PM
Fairly simple bit of code, I think. Not tested extensively yet.


// Put this somewhere near the top.
setvar("BaleCC_useConsumptionHelpers", FALSE);

// Skip down to where the code would be added. Presumably in get_cookie(),
// in the while(toEat()) loop.
if(vars["BaleCC_useConsumptionHelpers"].to_boolean()) {
item milk = $item[Milk of Magnesium];
item pill = $item[munchies pill];
int mpa = get_property("valueOfAdventure").to_int();
if(have_effect($effect[Got Milk])==0 && mpa>historical_price(milk) && retrieve_item(1, milk)) use(1, milk);
if(3*mpa>historical_price(pill) && retrieve_item(1, pill)) use(1, pill);
}


Or, if you want to be slightly more like Zarqon, you can rewrite the last two if statements as:

((!(have_effect($effect[Got Milk])==0 && mpa>historical_price(milk) && retrieve_item(1, milk) && use(1, milk)) && 0>1) || (3*mpa>historical_price(pill) && retrieve_item(1, pill) && use(1, pill)));

(I could've done the same thing for the whole snippet, but there'd be a lot of unnecessary repetition.)

Edit: Minor error in the code -- forgot that get_property() returns a string, which has to be converted to an int. Fixed.

Double edit: Changed the code to account for the possibility that the user already has Got Milk active.
Triple edit: Ack, forgot that if the first one returns true, the second won't be executed. Changed.

zarqon
11-08-2010, 02:58 PM
Haha, not quite -- use() has an unreliable return value and can't be included in otherwise delightfully uninterrupted condition chains. :)

Veracity
11-08-2010, 04:04 PM
Haha, not quite -- use() has an unreliable return value and can't be included in otherwise delightfully uninterrupted condition chains. :)
Uh huh.

Didn't I ask you to file bug reports for ASH functions with "unreliable" or otherwise not useful return values? Let's see:

Here (http://kolmafia.us/showthread.php?1965-MacGuffin-2.0-level-11-quest-automated&p=13007&viewfull=1#post13007) is zarqon (quickly followed by Bale) complaining about return values of various functions. May 29, 2009.
Here (http://kolmafia.us/showthread.php?3113-autoBasement.ash-Better-basement-automation&p=23037#post23037) is me asking for bug reports to be pinned for specific functions with useless return values, and zarqon saying he'd write reports after working up tests to demonstrate the problems. Jan 19, 2010.
Here (http://kolmafia.us/showthread.php?2072-ZLib-Zarqon-s-useful-function-library&p=24109&viewfull=1#post24109) is zarqon admitting that he'll get around to testing the "unreliable" functions and writing up bug reports - someday. Someday after Feb 10, 2010. ;)

I've seen no bug reports from you or Bale or anybody else, so the issue is not on my personal bug radar...

heeheehee
11-08-2010, 04:12 PM
Zarqon -- even so, it's at the end of each mini-chain, so it should still execute, no?

(edit: wouldn't Mafia abort if use() returned a false value? So technically the second way's safer.)

zarqon
11-08-2010, 04:28 PM
@3hee: Yes, actually, that would work fine!

@Veracity: I don't think it's possible to make use() have a reliable return value -- there are too many varying results, it would be a detection madness! MADNESS! So I haven't reported it. I was mentioning it here not as a complaint -- just pointing out the way things are.

The problems I'd had with create() seem to have been caused by some inaccuracies in the data files, which have since been fixed. And hermit() has very limited application, so I didn't mind scripting around it -- and once I had, it fled from my otherwise occupied mind.

I apologize for making you waste your time (which we all value almost as much as we value our mothers!) putting together that forum post. Those issues fell off my radar a while back too. Probably not too long after Feb 10, 2010. :)

Bale
11-08-2010, 10:53 PM
For some reason, it REALLY wants to run the eating of the cookie right before it does the adventuring, enough so that I actually completely removed the eatcookie function from my copy of CounterChecker. It may have to do with adding CanAdv to my copy, not sure.

What I was wondering is, if it's possible to have it check if the counter has been reset back to its range of 40... 159-199, 160-200, etc. As it does after actually finding the semi-rare.

The setup around how it was running was that it was set to timely (the default), using counterchecker as its counter script and zarqon's BBB as its between battle script. The behaviour was that it would start the CanAdv check (with prep as false), decide where to go, run CanAdv (with prep to true), eat a fortune cookie, THEN run the actual adventure. Because KoLmafia resets the cookie counter on semirare acquisition to 160-200, it would then decide that it didn't need to eat another cookie.

With the auto-recookie removed from CounterChecker and auto_semirare set to always, BBB still triggers eating a cookie BEFORE the semi-rare adventure, but will actually eat one the turn after as well. Not sure what's triggering the precookie-ing part. Guessing it's somehow tied into the new CanAdv checks though. On a positive note, using my copy of CanAdv that actually checks if the Knob is unlocked, haven't wasted a Semirare encounter since though...

Huh?! You're saying it eats a cookie before getting the semi-rare?! I cannot imagine this script doing that. I don't have time to investigate BBB for the problem, so zarqon can you see if your script is doing this?

Theraze, I'm not using that canadv patch of yours, so you're on your own checking it out. I think this is not MY bug.

Theraze
11-08-2010, 11:09 PM
Yeah... I got tired of the script sending me to the harem before I'd unlocked it. :D I tend to lazily run up to level 7-8 in the hidden temple, then finish all the level quests below in a simple rush. Helps because I'm doing BM, else I'd make it more optimal. Anyways, as my unlocking of those zones is really not guaranteed, the CC script was wasting more semirares than it actually would get, as it would fail to get the semirare, eat a cookie, and decide that it had done its job.

I'll keep tweaking it around, but for now, I suppose my best solution is to just keep the eatcookie part out of my CC, and just let BBB handle things.

zarqon
11-09-2010, 02:46 AM
I don't think this is Bale's bug either. I'm using a cut-up version of CC with lots of stuff removed (including fortune cookie handling), and I've noticed that BBB needs a little tweaking; when CC sends you to get the semirare, the counter that triggered the script is evidently no longer active, but the new window counters have not yet been set, so basically you're in a completely unknown state. Need to bump a number on one of the get_counters() calls.

Theraze
11-09-2010, 05:14 AM
Yeah... here's a log of the way it's running now.
Using 1 dance card...
Finished using 1 dance card.
Checking counters now.
Checking resistance to stench...
Searching items for stench resistance...
Resistance-granting item found: Knob Goblin harem veil
Getting a Dogsgotnonoz pills which is currently selling in the mall for 18,600 meat.
Internal checkpoint created.
Since you are not in a Mysticality sign, you may not visit the restaurant.
Searching for "fortune cookie"...
Purchasing fortune cookie (1 @ 40)...
You acquire an item: fortune cookie
You spent 40 Meat
Purchases complete.
Eating 1 fortune cookie...
You gain 1 Adventure
Lucky numbers: 79, 148, 168
Finished eating 1 fortune cookie.
Visit to BatHole: Batrat and Ratbat Burrow in progress...
[1689] Batrat and Ratbat Burrow
Encounter: How Does He Smell?
You acquire an item: Dogsgotnonoz pills
[1690] Haunted Ballroom
Encounter: floating platter of hors d'oeuvres
Strategy: C:\Program Files (x86)\KoLMafia\ccs\default.ccs [default]
Round 0: Theraze wins initiative!
(unable to macrofy due to action: consult SmartStasis.ash)
Round 1: Theraze executes a macro!
Round 1: Theraze attacks!
Round 2: floating platter of hors d'oeuvres takes 99 damage.
Round 2: Theraze attacks!
Round 3: floating platter of hors d'oeuvres takes 99 damage.
You acquire an item: desiccated apricot
You gain 15 Strongness
You gain 6 Enchantedness
You gain 9 Smarm
Since you are not in a Mysticality sign, you may not visit the restaurant.
Searching for "fortune cookie"...
Purchasing fortune cookie (1 @ 40)...
You acquire an item: fortune cookie
You spent 40 Meat
Purchases complete.
Eating 1 fortune cookie...
You gain 1 Adventure
Lucky numbers: 48, 237, 182
Lucky number 48 ignored - too soon to be a semirare.
Lucky number 237 ignored - too large to be a semirare.
Finished eating 1 fortune cookie.

zarqon
11-09-2010, 05:26 AM
Yeah, just needs to disregard cookies when you actually have a counter expiring. Just have to change a 1 to a 0, or a 0 to a -1 or something. I'll look into it soon. Either way, it's not CC's doing and this discussion can be finished in the CC thread. In the meantime, may I recommend "timely" as a superior fortune cookie setting?

Theraze
11-09-2010, 05:49 AM
Timely just eats (currently) the single cookie before the adventure, then never eats another when it's actually time. Sort of aggravated me until I figured that out.

Theraze
11-18-2010, 06:08 PM
Just got the new version of BBB, which sets the FC check to -1 instead of 0 as its minimum. If it actually properly makes itself/CC eat cookies when it should, I'll post my tweaked version here for perusal. If it's still odd, I'll delay until I've figured out what's screwing it up. :) Did also set CC to use -1 as its minimum, like BBB.

Bale
11-18-2010, 09:04 PM
Did also set CC to use -1 as its minimum, like BBB.

Why? BBB is at 0 before the semi-rare adventure. CC eats cookies after getting the semi-rare adventure.

Theraze
11-18-2010, 10:06 PM
Because while BBB was set before to look for 0 to 200 counters, as was CC, it was triggering before the adventure. zarqon changed his check to -1 to 200, and it made sense... if the counter is at -1, it's still not time to eat a cookie. When mafia finds a semirare, it sets the counter to 160-200, so finding a -1 counter shouldn't ever cause it to eat a cookie. When I run adventures tonight, I'll check if it works as it should (one cookie eaten, AFTER the semirare) using both at -1 min. If it does, I'll try BBB at -1, CC at 0 and see if it still works. I'll try to remember to report back either way. :)

Theraze
11-19-2010, 03:57 AM
Unfortunate...
Request 4 of 24 (Knob: Knob Goblin Treasury) in progress...
Checking for updates (running CounterChecker ver. 1.4)...
_version_BaleCC => 1.4
You have a current version of CounterChecker.
Checking counters now.
Checking resistance to stench...
Searching items for stench resistance...
Resistance-granting item found: Knob Goblin harem veil
unlockedLocations => 5-- Haunted Kitchen Haunted Billiards Room
unlockedLocations => 5-- Haunted Kitchen Haunted Billiards Room Knob Goblin Harem
Getting a Knob Goblin lunchbox which is currently selling in the mall for 22,888 meat.
Internal checkpoint created.
Since you are not in a Mysticality sign, you may not visit the restaurant.
Searching for "fortune cookie"...
Purchasing fortune cookie (1 @ 40)...
You acquire an item: fortune cookie
You spent 40 Meat
Purchases complete.
Eating 1 fortune cookie...
You gain 1 Adventure
Lucky numbers: 145, 29, 282
Lucky number 282 ignored - too large to be a semirare.
Finished eating 1 fortune cookie.
Visit to Knob: Outskirts of The Knob in progress...
[263] Outskirts of The Knob
Encounter: Lunchboxing
You acquire an item: Knob Goblin lunchbox
Conditions not satisfied after 1 adventure.
[264] Knob Goblin Treasury
Encounter: Knob Goblin Bean Counter
Strategy: C:\Program Files (x86)\KoLMafia\ccs\default.ccs [default]
Round 0: Theraze loses initiative!
(unable to macrofy due to action: consult SmartStasis.ash)
1/4 monsters drop goals here.
Round 1: Theraze executes a macro!
Round 1: Theraze attacks!
Round 2: knob goblin bean counter takes 12 damage.
Round 2: Theraze attacks!
Round 3: knob goblin bean counter takes 11 damage.
You gain 61 Meat
You acquire an item: hill of beans
You gain 5 Strongness
You gain 1 Mysteriousness
Since you are not in a Mysticality sign, you may not visit the restaurant.
Searching for "fortune cookie"...
Purchasing fortune cookie (1 @ 40)...
You acquire an item: fortune cookie
You spent 40 Meat
Purchases complete.
Eating 1 fortune cookie...
You gain 1 Adventure
Lucky numbers: 174, 96, 147
Lucky number 96 ignored - too soon to be a semirare.
Lucky number 147 ignored - too soon to be a semirare.
Finished eating 1 fortune cookie.

So, not quite happy yet. I need to make it display whose eat_cookie it's doing...

Theraze
11-29-2010, 01:42 PM
Okay, so managed to get BBB and CC to play nicely together by doing the following. I'll post the solutions in both threads, as both need some tweaking. This version does post updates, since it uses a mafia variable, but it could be converted to use a zlib variable for silence if preferred.

To CC, where it sets the locale, like so:
string last_rare = get_property("semirareLocation");
location locale = expensive_semi(last_rare);
string billiard = "2";add a line for setting what that locale is:
string last_rare = get_property("semirareLocation");
location locale = expensive_semi(last_rare);
set_property("nextSemirareLocation", locale);
string billiard = "2";

Then, after it's done with the turn, clean up the setting...
eat_cookie();
}becomes
eat_cookie();
set_property("nextSemirareLocation", "");
}


BBB then needs to be modified to respect that if nextSemirareLocation happens to be the place where we're going next, don't try to eat cookies, regardless of whether or not it's on the good cookie list. Change the following:
case "always": case "true":
while (get_counters("Fortune Cookie",-1,200) == "" ||
(to_int(cooks.group(2)) > 0 && count(split_string(get_counters("Fortune Cookie",0,200),"\t")) > to_int(cooks.group(2)))) {to this:
case "always": case "true":
while (my_location() != to_location(get_property("nextSemirareLocation")) && (get_counters("Fortune Cookie",-1,200) == "" ||
(to_int(cooks.group(2)) > 0 && count(split_string(get_counters("Fortune Cookie",0,200),"\t")) > to_int(cooks.group(2))))) {

Basically, encapsulating the current check with a validation that we don't have a nextSemirareLocation active and that it isn't set to our current location. By doing it as a check instead of being a boolean, if something crashes out we don't completely break BBB's ability to re-cookie us, since CC will only cookie us if it's doing it in conjunction with one of the counters ticking off.

Theraze
12-03-2010, 06:30 AM
And... worked fine tonight.
Request 10 of 45 (Mountain: Barrel full of Barrels) in progress...
Checking for updates (running CounterChecker ver. 1.4)...
_version_BaleCC => 1.4
You have a current version of CounterChecker.
Checking counters now.
You need a 'map to Vanya's Castle' to adventure here.
You need a 'dingy dinghy' to adventure here.
You need to be level 8 or higher to adventure at Goatlet.
Checking resistance to stench...
Searching items for stench resistance...
Unable to resist stench!
unlockedLocations => 6-- Haunted Kitchen Haunted Billiards Room
Searching for "cube of billiard chalk"...
You need a 'Spookyraven library key' to adventure here.
Searching for "tasty tart"...
You need to be level 11 or higher to adventure at Hidden City.
You need a 'dingy dinghy' to adventure here.
unlockedLocations => 6-- Haunted Kitchen Haunted Billiards Room Knob Goblin Harem
You need a 'Cobb's Knob lab key' to adventure here.
You need a 'Cobb's Knob lab key' to adventure here.
You need to be level 8 or higher to adventure at Ninja Snowmen.
You need to be level 9 or higher to adventure at Orc Chasm.
You need a 'dingy dinghy' to adventure here.
You need at least 40 Mysticality to adventure at Post-Cyrpt Cemetary.
Searching for "distilled fortified wine"...
You need to be level 7 or higher to adventure at Whitey's Grove.
Getting 3 bottles of distilled fortified wine which are currently selling in the mall for 5690 meat each.
New ZLib location setting: BaleCC_nextSemirareLocation => Sleazy Back Alley
Internal checkpoint created.

Restoring HP! Currently at 3 of 31 HP, 21 of 51 MP, current meat: 24 ... Target HP = 30.
Insufficient meat to fully restore HP without wasting restoratives!
Did not fully restore HP for some reason.

Visit to Town: Sleazy Back Alley in progress...

[244] Sleazy Back Alley
Encounter: In the Still of the Alley
You acquire distilled fortified wine (3)

Visiting Hell's Kitchen...
Menu retrieved.
Since you are not in a Mysticality sign, you may not visit the restaurant.
You need 1 more fortune cookie to continue.
Fortune Cookie counter expired. Last semirare found 0 turns ago (on turn 244) in Sleazy Back Alley Well, with the exception of not having enough meat to buy the cookie post-SR. Joys of lazy BM runs. Anyways, modified parts follow... and there are rather a few. :)
script "CounterChecker.ash";
notify Bale;
import <canadv.ash>
check_version("CounterChecker", "BaleCC", "1.4", 2519);
// This will return the location of the currently most expensive semi-rare
location expensive_semi(string last) {
item [location] semi_rare;
semi_rare[$location[The Purple Light District]] = $item[lewd playing card];
semi_rare[$location[Haunted Billiards Room]] = $item[cube of billiard chalk];
semi_rare[$location[Menagerie 2]] = $item[irradiated pet snacks];
semi_rare[$location[Outskirts of The Knob]] = $item[Knob Goblin lunchbox];
semi_rare[$location[Limerick Dungeon]] = $item[cyclops eyedrops];
semi_rare[$location[Sleazy Back Alley]] = $item[distilled fortified wine];
semi_rare[$location[Haunted Pantry]] = $item[tasty tart];
semi_rare[$location[Harem]] = $item[scented massage oil];
semi_rare[$location[Haunted Kitchen]] = $item[freezerburned ice cube];
semi_rare[$location[Haunted Library]] = $item[black eyedrops];
semi_rare[$location[Goatlet]] = $item[can of spinach];
semi_rare[$location[Ninja Snowmen]] = $item[bottle of antifreeze];
semi_rare[$location[Orc Chasm]] = $item[ASCII shirt];
semi_rare[$location[Battlefield (No Uniform)]] = $item[six-pack of New Cloaca-Cola];
semi_rare[$location[Batrat and Ratbat Burrow]] = $item[Dogsgotnonoz pills];
semi_rare[$location[Giant's Castle]] = $item[Mick's IcyVapoHotness Inhaler];
semi_rare[$location[Guano Junction]] = $item[Eau de Guaneau];
semi_rare[$location[Laboratory]] = $item[bottle of Mystic Shell];
semi_rare[$location[Pre-Cyrpt Cemetary]] = $item[poltergeist-in-the-jar-o];
semi_rare[$location[Post-Cyrpt Cemetary]] = $item[poltergeist-in-the-jar-o];
semi_rare[$location[South of The Border]] = $item[donkey flipbook];
semi_rare[$location[Friars Gate]] = $item[SPF 451 lip balm];
semi_rare[$location[Hidden City]] = $item[shrinking powder];
semi_rare[$location[8-Bit Realm]] = $item[fire flower];
semi_rare[$location[Spooky Forest]] = $item[fake blood];
semi_rare[$location[Whitey's Grove]] = $item[bag of lard];
semi_rare[$location[Hippy Camp]] = $item[teeny-tiny magic scroll];
semi_rare[$location[Frat House]] = $item[bottle of rhinoceros hormones];
semi_rare[$location[Pirate Cove]] = $item[bottle of pirate juice];
semi_rare[$location[Burnbarrel Blvd]] = $item[jar of squeeze];
semi_rare[$location[Exposure Esplanade]] = $item[bowl of fishysoisse];
semi_rare[$location[The Heap]] = $item[concentrated garbage juice];
semi_rare[$location[The Ancient Hobo Burial Ground]] = $item[deadly lampshade];
semi_rare[$location[Chapel]] = $item[pixel stopwatch];
remove semi_rare[last.to_location()];

int[item] semi_rare_multiplier;
semi_rare_multiplier[$item[distilled fortified wine]] = 3;
semi_rare_multiplier[$item[tasty tart]] = 3;
semi_rare_multiplier[$item[scented massage oil]] = 3;
// This finds out if the PLD can be accessed for semi-rare usage.
if(last != "The Purple Light District") {
if(visit_url("town_clan.php").contains_text("clanbasement.gif")
&& !visit_url("clan_basement.php?fromabove=1").contains_text("not allowed")) {
buffer pld = visit_url("clan_hobopolis.php?place=8&pwd");
if(!pld.contains_text("purplelightdistrict") || pld.contains_text("purplelightdistrict11.gif"))
remove semi_rare[$location[The Purple Light District]];
// purplelightdistrict11.gif == Chester defeated.
} else
remove semi_rare[$location[The Purple Light District]];
remove semi_rare[$location[The Ancient Hobo Burial Ground]];
remove semi_rare[$location[The Heap]];
remove semi_rare[$location[Exposure Esplanade]];
remove semi_rare[$location[Burnbarrel Blvd.]];
}

int [item] prices;
int expensive = 0;
int rare_price;
location best = $location[none];
foreach locale, rare in semi_rare {
if (!can_adv(locale,false))
continue;
if(historical_age(rare) > 1 || historical_price(rare) == 0)
mall_price(rare);
if(semi_rare_multiplier contains rare)
rare_price = semi_rare_multiplier[rare] * historical_price(rare) ;
else rare_price = historical_price(rare) ;
if( rare_price > expensive) {
best = locale;
expensive = rare_price;
}
}
void get_semirare() {
int last = get_property("semirareCounter").to_int();
void eat_cookie() {
if(get_property("semirareCounter").to_int() != last) {
// semi-rare acquired, let's do it again
if(my_fullness() == fullness_limit())
print("If I ate even a fortune cookie I'd burst! Remember to eat a fortune cookie when the tummy is emptier.", "red");
else while(toEat())
eatsilent(1, $item[fortune cookie]);
} else
print("Oops, that wasn't the right number!", "red");
}

string last_rare = get_property("semirareLocation");
location locale = expensive_semi(last_rare);
vars["BaleCC_nextSemirareLocation"] = locale;
updatevars();
cli_execute("checkpoint");
can_adv(locale,true);
string billiard = "2";
// If ImprovePoolSkills, then play a game of pool at every opportunity!
if(ImprovePoolSkills && last_rare != "Haunted Billiards Room") {
locale = $location[Haunted Billiards Room];
billiard = get_property("choiceAdventure330");
if(billiard != "1")
set_property("choiceAdventure330", "1");
}
else if(locale == $location[Haunted Billiards Room]) {
billiard = get_property("choiceAdventure330");
if(billiard != "2")
set_property("choiceAdventure330", "2");
}
(!adventure(1, locale));
if(locale == $location[Haunted Billiards Room] && billiard != get_property("choiceAdventure330"))
set_property("choiceAdventure330", billiard);
outfit("checkpoint");
remove vars["BaleCC_nextSemirareLocation"];
updatevars();
eat_cookie();
}

Theraze
12-03-2010, 05:03 PM
Updated the post above to have the vars[] and updatevars() instead of using setvar, since we're not just setting a default, we're wanting to change an existing value... Suppose it's time to ask for a removevar command or something similar. :)

Note: To just make this be less cruel to BBB, the fix is just the nextSemirareLocation being set and unset with its lines before and after the adventuring. I also streamlined the billiards handling to use the same adventure and exit as the normal bit.

CanAdv affects the first two patch locations... to skip implementing that, ignore those two codeblocks completely. The specific changes near the end that involve CanAdv are the checkpoint, can_adv(), and outfit("checkpoint") lines. Besides that, the rest of the get_semirare function should act exactly the same as the current one (except with setting the value so BBB doesn't try to eat its cookie too quickly).

Theraze
12-04-2010, 04:24 AM
Applied slyz's tip on removing variables to the semirare bit. Should clean things up better now. Will note if it fails, but otherwise it should work.

Winterbay
12-06-2010, 07:29 AM
Trying this out...

So, what does the
(!adventure(1, locale)); part do? I mean what is the point of the parenthesis and the !-symbol since it isn't in a boolean check?

Bale
12-06-2010, 08:08 AM
If adventure returns false the script will abort. It will always return false if there is an active condition. :( By capturing the false return value I prevent the script from aborting.

More information: http://wiki.kolmafia.us/index.php?title=Tips,_Tricks_and_Workarounds#Captu ring_an_Abort

Winterbay
12-06-2010, 10:09 AM
Right. I should've known there was some good reason :)
I've only done error catching sofar (ie putting the result into a variable and check for it, not an implicit use of the return value itself).

me259259
12-11-2010, 12:52 AM
Is there a way to get a specific semi-rare using counterchecker? Instead of it searching for the semi-rares with the best mallprice, can you switch it to a mode where it gets only a couple of user defined semi-rares?

Bale
12-11-2010, 04:48 AM
You'd have to edit it. For instance, if you do this:


location expensive_semi(string last) {
if(last != "Elf Alley")
return $location[Elf Alley];
...

Then it will always go to Elf Alley if you weren't there last. Unfortunately that code doesn't include any checks to see if Elf Ally is actually available, so you'd best make sure of that yourself. Sadly I haven't updated this script for some time.

Theraze
12-11-2010, 06:13 AM
me259, easiest thing to do is delete all but the 2-3 semirares you want it to harvest. It'll switch between the choices you allow it automatically. But nothing says you need to leave in all the choices that exist currently... or even says that you can't add in more. :)

me259259
12-13-2010, 09:20 PM
Thank you! Soon there won't be a semi-rare that can hide from me...

Captain Kirk
12-27-2010, 03:45 PM
Could you add a zlib option to use a munchies pill with a fortune cookie?
Thanks for pointing this script out to me when we were chatting!

Bale
12-27-2010, 03:56 PM
I suppose I could do that. I think the value of the zlib variable should be the maximum price to pay for the munchie pill. A price of 0 would refuse to use one. (Though honestly if there was a pill for 100 meat it would be stupid not to use one.) Does that sound good?

Captain Kirk
12-29-2010, 02:41 AM
I suppose I could do that. I think the value of the zlib variable should be the maximum price to pay for the munchie pill. A price of 0 would refuse to use one. (Though honestly if there was a pill for 100 meat it would be stupid not to use one.) Does that sound good?

Well, in the case where I would set this variable it would be during crimbo (or other special events), in which case I would have farmed up a large supply of munchies pills ahead of time. So as long as it understands that it wants to use munchines pills already in your inventory (no matter the price), then that is ok with me.

slyz
12-29-2010, 02:55 AM
So as long as it understands that it wants to use munchines pills already in your inventory (no matter the price), then that is ok with me.
Whether they are in your inventory or not shouldn't be relevant. When you use a pill from your inventory, it costs you since you could have sold it in the mall.

You could see the zlib setting Bale is proposing as the threshold at which you would rather sell them for meat rather than use them to get more adventures.

vert
01-26-2011, 01:09 PM
Looks like the Friar's Gate update has broken this script:



Visit to Island: Frat House (Stone Age) in progress...
Bad location value: "Friar's Gate" (CounterChecker.ash, line 511)
Fortune Cookie counter expired. Last semirare found 337 turns ago (on turn 71175) in Outskirts of The Knob

Winterbay
01-26-2011, 01:41 PM
It's interesting that it complains on line 511 when the real problem, to me at least, seems to be on line 74 or so (give or take one or two due to modifications). Change of Friars gate to Pandamonium Slums should solve it, or at least mine stopped aborting when I did that :)

Bale
01-26-2011, 07:24 PM
This script requires a serious overhaul. Maybe this error will inspire me to finally do that...

Raven434
01-28-2011, 12:34 PM
Thanks for the update Bale!

:)

alfagetti
01-30-2011, 03:24 AM
Hi everyone,

First, thanks very much Bale for making this script, and for updating it so quickly after the Pandamonium update!

Next, I am looking for a little help.

I am running this script (as well as Universal Recovery, Smart_stasis and First Things First) alongside BCC's Ascension script. I am trying to get the script to abort when my fortune cookie counter expires, but without much luck; the CounterChecker tells me the following...

Request 4 of 16 (Beanstalk: Giant's Castle) in progress...
(cli abort counter discarded due to conflict)
Checking for updates (running CounterChecker ver. 1.41)...
_version_BaleCC => 1.41
You have a current version of CounterChecker.
Checking counters now.
Semi-rares choices are not automated in hardcore or ronin.
Your last semi-rare adventure was at Knob Goblin Harem, so plan accordingly.
Fortune Cookie counter expired. Last semirare found 353 turns ago (on turn 446) in Knob Goblin Harem


and then the BCC script continues on its way.

Recently, i've been trying to use the following command "counters add X cli abort" to try and abort it. it was working (well, kinda) and today its got a conflict.

I am not an ASH scripter (but wouldn't mind trying my hand at it one day!), but would appreciate any suggestions/tips regarding how to get CounterChecker to stop!

Thanks very much for listening to this noob :)

Theraze
01-30-2011, 03:47 AM
Easiest thing to do is to remove the semirare items you don't want, and turn on SRinHC setting...

alfagetti
01-30-2011, 03:56 AM
Easiest thing to do is to remove the semirare items you don't want, and turn on SRinHC setting...

Thanks for the quick reply!

The reason i haven't done this yet is i was concerned it would just default to getting one or 2 items (i.e. alternate between cyclops eyedrops and knob goblin lunchboxes) since i understood it would always attempt to get the most expensive item market-wise. What if i want shrinking powder? What if i only want one eyedrops and 2 inhalers?

I really just want it to stop when the counter expires. What would happen if i removed ALL locations?

Theraze
01-30-2011, 04:00 AM
Well, it can only get from whatever list you give it... if you want shrinking powder and a lunchbox, put those two in the list and remove the rest. If you want it to alternate between eyedrops and inhalers, remove everything but the limerick and castle. The script does what you tell it to, when it's time...

Just remember to leave at least 2 items, so it can alternate.

Weatherboy
01-30-2011, 04:30 AM
I guess I'm going to have to look in the code and add a case statement or something, because I'm running 3 characters; one in HC, one in BM/HC, and one in softcore. They all have different needs in run.

Theraze
01-30-2011, 04:51 AM
Just drop in a switch (my_name()) bit, case "Weatherboy", etc?

Check on newLife, the "special" function. Bale has it check on character name there.

Winterbay
01-30-2011, 08:42 AM
I've modified the start of my expensive_semi()-function to look like this:



location expensive_semi(string last)
{
item [location] semi_rare;
if(can_interact())
{
semi_rare[$location[The Purple Light District]] = $item[lewd playing card];
semi_rare[$location[Haunted Billiards Room]] = $item[cube of billiard chalk];
semi_rare[$location[Menagerie 2]] = $item[irradiated pet snacks];
semi_rare[$location[Outskirts of The Knob]] = $item[Knob Goblin lunchbox];
semi_rare[$location[Limerick Dungeon]] = $item[cyclops eyedrops];
semi_rare[$location[Sleazy Back Alley]] = $item[distilled fortified wine];
semi_rare[$location[Haunted Pantry]] = $item[tasty tart];
semi_rare[$location[Harem]] = $item[scented massage oil];
semi_rare[$location[Haunted Kitchen]] = $item[freezerburned ice cube];
semi_rare[$location[Haunted Library]] = $item[black eyedrops];
semi_rare[$location[Goatlet]] = $item[can of spinach];
semi_rare[$location[Ninja Snowmen]] = $item[bottle of antifreeze];
semi_rare[$location[Orc Chasm]] = $item[ASCII shirt];
semi_rare[$location[Battlefield (No Uniform)]] = $item[six-pack of New Cloaca-Cola];
semi_rare[$location[Batrat and Ratbat Burrow]] = $item[Dogsgotnonoz pills];
semi_rare[$location[Giant's Castle]] = $item[Mick's IcyVapoHotness Inhaler];
semi_rare[$location[Guano Junction]] = $item[Eau de Guaneau];
semi_rare[$location[Laboratory]] = $item[bottle of Mystic Shell];
semi_rare[$location[Pre-Cyrpt Cemetary]] = $item[poltergeist-in-the-jar-o];
semi_rare[$location[Post-Cyrpt Cemetary]] = $item[poltergeist-in-the-jar-o];
semi_rare[$location[South of The Border]] = $item[donkey flipbook];
semi_rare[$location[Pandamonium Slums]] = $item[SPF 451 lip balm];
semi_rare[$location[Hidden City]] = $item[shrinking powder];
semi_rare[$location[8-Bit Realm]] = $item[fire flower];
semi_rare[$location[Spooky Forest]] = $item[fake blood];
semi_rare[$location[Whitey's Grove]] = $item[bag of lard];
semi_rare[$location[Hippy Camp]] = $item[teeny-tiny magic scroll];
semi_rare[$location[Frat House]] = $item[bottle of rhinoceros hormones];
semi_rare[$location[Pirate Cove]] = $item[bottle of pirate juice];
semi_rare[$location[Burnbarrel Blvd]] = $item[jar of squeeze];
semi_rare[$location[Exposure Esplanade]] = $item[bowl of fishysoisse];
semi_rare[$location[The Heap]] = $item[concentrated garbage juice];
semi_rare[$location[The Ancient Hobo Burial Ground]] = $item[deadly lampshade];
semi_rare[$location[Chapel]] = $item[pixel stopwatch];
}
else
{
semi_rare[$location[Outskirts of The Knob]] = $item[Knob Goblin lunchbox];
semi_rare[$location[Sleazy Back Alley]] = $item[distilled fortified wine];
semi_rare[$location[Haunted Pantry]] = $item[tasty tart];
semi_rare[$location[Harem]] = $item[scented massage oil];
semi_rare[$location[Giant's Castle]] = $item[Mick's IcyVapoHotness Inhaler];
semi_rare[$location[Hidden City]] = $item[shrinking powder];
}
remove semi_rare[last.to_location()];

int[item] semi_rare_multiplier;
semi_rare_multiplier[$item[distilled fortified wine]] = 3;
semi_rare_multiplier[$item[tasty tart]] = 3;
semi_rare_multiplier[$item[scented massage oil]] = 3;
if((!can_interact() && item_amount($item[Mick's IcyVapoHotness Inhaler]) == 0) || (!can_interact() && item_amount($item[shrinking powder]) == 0))
{
semi_rare_multiplier[$item[Mick's IcyVapoHotness Inhaler]] = 10;
semi_rare_multiplier[$item[shrinking powder]] = 10;
}


I.e. if I'm unable to interact (i.e. being in HC) it only uses the trimmed list and since I want to have a shrinking powder and a Inhaler for the level 12 quest I've set it so that those are upvalued by a factor of 10 when I don't have any of them. This seemed to be working just fine together with BCCs script and SRinHC = true.

alfagetti
01-31-2011, 01:35 AM
Winterbay, thanks very much for that modification! And thank you all for being so patient :)

Weatherboy
01-31-2011, 03:28 AM
Yeah, Winterbay, that's exactly what I was thinking of doing. The if(!can_interact() && item_amount($item[item])==0) would be a growing list based on character. IE, my softcore dude only gets 3 SR's per run, so the list would include only KGE, ascii, and inhaler; if the I have more than zero, it removes it from the list until there is only the inhaler remaining. I'll add massage oil, pet snacks and cyclops eyedrops for my low-skilled HC characters. Very nice. Thanks.

Winterbay
01-31-2011, 08:08 AM
Interesting fact: If the random square that counterchecker.ash chooses in the Hidden City is a former protector spirit it will think that it was the incorrect adventure to find a semirare, even though it may not have been.

Bale
01-31-2011, 08:31 AM
Interesting fact: If the random square that counterchecker.ash chooses in the Hidden City is a former protector spirit it will think that it was the incorrect adventure to find a semirare, even though it may not have been.

Thanks for the tip. I'll keep that in mind when the day comes that I add that semi-rare to the script. It's a pretty easy fix. In the meantime, anyone using your mod had best be careful.

Winterbay
01-31-2011, 08:50 AM
Indeed. I think I'll have to poke at it a bit.

Bale
01-31-2011, 09:07 AM
Well, the good news is that I'm finally adding in the rest of the semi-rares and so forth. Yay, me.

I may even allow the user to define a list of semi-rares that he wants to get in hardcore so that the script can just get the next one on the list.

alfagetti
01-31-2011, 01:15 PM
Thanks very much Winterbay and Bale for the warning re: Hidden city...i have seen that behavior before, but hadn't considered it would impact the script!

And thank you Bale, for continuing the great work!

Theraze
01-31-2011, 01:38 PM
Hmm... Okay, adding in the HiddenCity script to my version so it can do its get_first("e") check if it's going for a shrinking powder.

Also, if all the other locations are being added, does that mean CanAdv is being added, or just left to user's discression? The one issue I've found with CanAdv is regarding (generally the first semirare) pre-unlocking guild... it tries to unlock the guild, which uses adventures, and then the semirare adventure is lost, but the script isn't aware of it having happened. I may throw in an adventure check to see if the count is the same before and after the CanAdv($location, true) call.

slyz
01-31-2011, 06:57 PM
I may even allow the user to define a list of semi-rares that he wants to get in hardcore so that the script can just get the next one on the list.
I was going to post that getting user-defined ascension-relevant semi-rares was outside the scope of CounterChecker.ash. Making a counterScript that grabs a few user-defined SRs would be a lot simpler.

But if Bale decides to include this (along with a nifty user interface for the configuration, of course, since we now expect no less), people wouldn't need to give up the other awesome features, such as automatic absinth-levelling!

Bale
01-31-2011, 11:17 PM
Also, if all the other locations are being added, does that mean CanAdv is being added, or just left to user's discression? The one issue I've found with CanAdv is regarding (generally the first semirare) pre-unlocking guild... it tries to unlock the guild, which uses adventures, and then the semirare adventure is lost, but the script isn't aware of it having happened. I may throw in an adventure check to see if the count is the same before and after the CanAdv($location, true) call.

Yes and No. CanAdv does this and some other things that I don't like (such as vprinting about locations that may or may not be available and I don't want that output), so I am writing my own mini CanAdv based on that script and adding that function into CounterChecker. In other words you won't have to worry about CounterChecker unlocking your guild. If you don't unlock it yourself, the script won't try to get that semi-rare.

The next version of CounterChecker will work and play well with CanAdv's unlockedLocations preference.



I was going to post that getting user-defined ascension-relevant semi-rares was outside the scope of CounterChecker.ash. Making a counterScript that grabs a few user-defined SRs would be a lot simpler.

Yeah, but I'd actually use this feature. Go figure. That bumps it up from "outside the scope" to making it part of the scope.


But if Bale decides to include this (along with a nifty user interface for the configuration, of course, since we now expect no less), people wouldn't need to give up the other awesome features, such as automatic absinth-levelling!

I appreciate the compliment, but I'm not sure that I really want the trouble of making a UI for it. If people want the feature they can just set it as a zlib variable containing a list of locations.

Do people really think that there should be a relay script to configure CounterChecker? So you can have a checklist of semi-rares?



Hmm... Okay, adding in the HiddenCity script to my version so it can do its get_first("e") check if it's going for a shrinking powder.

It's a pretty short function, so I'm gonna simply copy it (thanks zarqon). After all, it's annoying to the user to make them download a variety of unassociated scripts.


int get_first_e() {
string prop = get_property("hiddenCityLayout");
for i from 1 to length(prop)
if (substring(prop,i-1,i) == "E") return i;
return 0;
}

heeheehee
01-31-2011, 11:59 PM
It's a pretty short function, so I'm gonna simply copy it (thanks zarqon). After all, it's annoying to the user to make them download a variety of unassociated scripts.


int get_first_e() {
string prop = get_property("hiddenCityLayout");
for i from 1 to length(prop)
if (substring(prop,i-1,i) == "E") return i;
return 0;
}

Hrm? Isn't there an index_of() function? (am slightly confused, please clarify.)

Theraze
02-01-2011, 12:05 AM
Used the adventure one instead of copying it mostly so that if the HiddenCity is completely undiscovered, it would still adventure in a square... not sure if you need to do anything, or if leaving it on exploring whatever number it's on (if it doesn't reset on ascension) works.

Bale
02-01-2011, 12:32 AM
Hrm? Isn't there an index_of() function? (am slightly confused, please clarify.)

Good point. I'd definitely be better doing:


int get_first_e() {
return index_of(get_property("hiddenCityLayout"), "E");
}

StDoodle
02-01-2011, 12:48 AM
Just don't forget to check for -1!

alfagetti
02-01-2011, 12:53 AM
I appreciate the compliment, but I'm not sure that I really want the trouble of making a UI for it. If people want the feature they can just set it as a zlib variable containing a list of locations.

Do people really think that there should be a relay script to configure CounterChecker? So you can have a checklist of semi-rares?


I think the relay script would be noob-friendly, but not necessary with instructions on how to modify zlib. Being a noob myself, i know i am always a bit nervous about monkeying around in scripts since i have no idea what i am doing.

However, it is a damn good exercise to make me do things like change zlib or add in bits of code (a la Winterbay's suggestion....although i screwed that up and missed the semi-rare again :( ), because that is forcing me to learn, which is the best way to get over this fear of breaking a script!

Theraze
02-01-2011, 01:31 AM
Not editing zlib... using zlib to set variables. Editing the variables in the script only helps if it's the first time you're running the script, else it's too late...

StDoodle
02-01-2011, 01:32 AM
I think it should get a relay script, but not just "for teh noobs." I also think the few of us who've written relay scripts should get together and agree on a few things that would be nice to add to / supplement htmlform.ash with, such that writing a configuration script or other "simple" things like this would become trivial. :)

alfagetti
02-01-2011, 04:03 AM
Not editing zlib... using zlib to set variables. Editing the variables in the script only helps if it's the first time you're running the script, else it's too late...

Thanks for the clarification...told you i was a n00b ;)

zarqon
02-01-2011, 04:51 AM
I'd appreciate if you submit any improvements you make to CanAdv in that thread. I hate CanAdv's placeholder guild handling but thus far no one (including myself) has had the time to write it properly.

As for interface, as soon as we can get items/monster dropdowns working, the WOSSMAN will even be able to normalize comma-delimited lists of any mafia type, such as items. I don't think a separate interface is necessary -- if you feel up to it, I'd love help tracking down that friggin' bug because it has completely halted my development of that otherwise very useful interface (which I would like to be the primary way ZLib settings are modified since it is utterly user-friendly).

Also, you'll need to add a "+1" to that index_of(), or you'll be adventuring in the wrong square (or possibly no square). Hidden City squares start at 1, not 0. Also also, then scripts would want to check for 0, not -1.

StDoodle
02-01-2011, 05:12 AM
As for interface, as soon as we can get items/monster dropdowns working...

I don't recall hearing about that one... any more info you could point me toward?

zarqon
02-01-2011, 05:29 AM
If you've downloaded the prototype WOSSMAN (http://kolmafia.us/showthread.php?2072-ZLib-Zarqon-s-useful-function-library&p=38185&viewfull=1#post38185) already, try editing a setting that is an item or monster. You can't -- it doesn't create the dropdown box. The WOSSMAN uses AJAX to ping itself to create the dropdown boxes for mafia's special types. They work for stats and familiars, and probably others (untested), but they are definitely broken for items and monsters, possibly locations.

And now, back to CC... (sorry Bale).

Bale
02-01-2011, 07:30 AM
Released CounterChecker v1.49

This is the "It's about bloody time" version. I've finally added all of the game's semi-rares and checks to see if those locations are adventure-able.

Rather than simply include zarqon's canadv, I use it as an outline with some improvements to cut down on server hits. One weakeness of canadv is that it hits a location (plains.php, woods.php, questlog.php?which=2, etc) every time it does a perm_urlcheck() for that location. Since I know I'll check a bunch, my revision only checks any given url once.

Somehow I suspect that I have messed something up so I'll be very eager to see Winterbay and Theraze's commentary.

Now that I've finished this essential update, my next step is to start working on a way for the users to list the semi-rares they want to get in hardcore so that it can try to get any of which the character has less than 1.

zarqon
02-01-2011, 09:11 AM
Thanks Bale -- I guess I will steal most of what you added. That or just delete CanAdv; thinking about that script just makes me upset. It was never finished but people generally complain about it like it is. Most of the time I wish I would never have asked everyone to work on it with me -- it's been far more trouble to me than helpful to other scripters, with too few people submitting actual fixes to help it reach completion. As evidenced by you today, preferring to write your own.

Also, what you describe as a weakness is intentional for a universally importable script. If you know you are going to check repeatedly without changing game state in between, you can store the results of can_adv() in a map outside the function -- rather than storing those results within can_adv(), rendering the function unfit for importing into a script which may take actions that unlock the zone between checks.

*goes home to eat gallons of ice cream*

Bale
02-01-2011, 09:48 AM
Also, what you describe as a weakness is intentional for a universally importable script.

I know, I know. That's why I didn't pop over to the CanAdv thread and post a big "Do this and make it better" post. There are all kinds of limitations with a universal script which I didn't have to cope with. I could just do whatever I liked. Mostly I enjoyed CanAdv as a big catalog of logic for checking each zone without needing to figure it out for myself. It was very helpful to me. If there's anything in my mini-CanAdv that actually helps the big project, please feel free to use it.

Winterbay
02-01-2011, 10:26 AM
I've re-added my can_interact()-check and will see what happenes. The first semirare is in about 75 turns, which could be today or early tomorrow :)

ETA: It gathered a nice knob goblin lunchbox without any problem. I thereby assume that at least some things in the script works :)

Theraze
02-01-2011, 02:20 PM
One note on the adventure check... 8-bit realms is checking for the existance of stat and an available continuum... but doesn't mafia automatically collect it if you try to adventure and don't have it yet? I've never had an issue with that... only with trying to adventure there when I'm using a 2 handed weapon. Maybe a better check would be for the 20 stat and a 1 handed weapon, so it can auto-equip the continuum (from inventory|after getting it from the crazy guy).

Edit: Not sure if the chapel goes the same way, or if it only auto-collects for the 8-bit realm and not for chapel. Anyways, chapel probably needs 1-handed check as well.

Edit2: Both have the 1-handed check when it's actually running the adventure, so you can probably just have it equip the 1 handed weapon and adventure, since mafia automatically handles getting/equipping the continuum... So the can adventure check above can just be for the stat, long as chapel acquires the continuum for you like the 8-bit realm.

Edit3: Not sure about areas that need resistances to visit... Guano Junction needs stench resistance, for example. When doing the CanAdv with prep, it would use the harem gear or something like that for stench resistance. There might be some other zones that have special gear that needs to be added still, but that's the main one I've seen often.

Bale
02-01-2011, 05:24 PM
Good points all.

Is it really necessary to have a 1-handed weapon? I can just remove your 2-handed weapon after all. Or is there fear of being weaponless when your counter is wrong? (It might be wrong if you only ate 1 cookie.)

Bale
02-01-2011, 06:31 PM
Released CounterChecker v1.491

I am very pleased with the solutions I found to the problems pointed out by Theraze.

Theraze
02-01-2011, 08:21 PM
Good points all.

Is it really necessary to have a 1-handed weapon? I can just remove your 2-handed weapon after all. Or is there fear of being weaponless when your counter is wrong? (It might be wrong if you only ate 1 cookie.)

Well, you need the 1 handed weapon just because if you have a 2-handed weapon in your main hand, you can't equip the continuum... Unless you have the 2 fisted smashings and all of that, but, yeah. The monsters are weak and would probably die from headbutts without too much work, it's just a matter of not wanting to potentially have it fail to adventure at all because the equipping failed. You do have the "checkpoint"/"outfit checkpoint" in there, so as long as you survive the combat, it shouldn't be too traumatic. :)

Side note... still a bug regarding prime mysticality and elemental resistances, because Mafia gives them a base of 5 elemental resistance. However, this only works for combat, not safe adventuring. Just need to make sure that pasta/saucers are > 5 instead of > 0. Actually went through this while updating the Rinn quest scripts to make Level 4 and 8 not hang.

Also, does Ninja Snowmen require cold? Can't remember.
Edit: Nope, doesn't.

StDoodle
02-01-2011, 09:54 PM
Well, you need the 1 handed weapon just because if you have a 2-handed weapon in your main hand, you can't equip the continuum... Unless you have the 2 fisted smashings and all of that, but, yeah.

That's .... not how that skill works at all. ;) 2-fisted skull smashing is what allows you to equip two 1-handed weapons at the same time. You can never equip a two-handed (or three-handed) weapon along with anything in your offhand.

Bale
02-01-2011, 10:03 PM
Side note... still a bug regarding prime mysticality and elemental resistances, because Mafia gives them a base of 5 elemental resistance. However, this only works for combat, not safe adventuring. Just need to make sure that pasta/saucers are > 5 instead of > 0. Actually went through this while updating the Rinn quest scripts to make Level 4 and 8 not hang.

WTF? Are you sure? That would be a bug since they don't get +5 resistance, they get +5% resistance... Not the same thing. And "modtrace stench resistance" shows no sign of it.

Theraze
02-01-2011, 10:42 PM
Well, this test:
if (elemental_resistance($element[stench]) == 0.0)returned false for my pasta/saucer... and ash elemental_resistance($element[stench]) returned 5.0 with nothing equipped...

Bale
02-01-2011, 11:07 PM
Ah. I understand! elemental_resistance returns the percentage of resistance so 5 is correct there. The values returned by maximizer and modtrace have a different meaning. That's awesome.



Released CounterChecker v1.492


This is the "unary is fun" fix.


boolean stinkup(boolean sim) {
if(elemental_resistance($element[stench]) > (my_primestat() == $stat[Mysticality]? 5: 0)) return true;
return maximize("1 max, 1 min, stench resistance, -tie, switch exotic parrot", sim);
}

Theraze
02-01-2011, 11:15 PM
Awesome. :) Looking forwards to trying it out tonight.

Theraze
02-02-2011, 03:48 AM
Just a note... using the current version of this, I'm still having issues between BBB and CC and their cookie eating behaviour (BBB eating a cookie before the CC adventure). Guess I'll be patching that back in. :D

Edit: So, what I did was this... between location locale and string billiard, added middle 2 lines to make it this:
location locale = expensive_semi(last_rare);
vars["BaleCC_nextSemirareLocation"] = locale;
updatevars();
string billiard;and just before eat_cookie at the end, remove it like this:
remove vars["BaleCC_nextSemirareLocation"];
updatevars();
eat_cookie();

Edit2: Also, the remove/update needs to happen to the billiard adventure as well, since this version has the adventure there instead of integrated. :)

Bale
02-02-2011, 04:47 AM
Didn't you also have to patch BBB to work with that?

I'm not going to make an official change to CC for BBB until zarqon makes an official change to BBB. This was his idea after all. Though I'd be glad to make any change that fits his idea of how it should be fixed.

Theraze
02-02-2011, 04:57 AM
Yeah, I patched both. We'll see if zarqon decides to include something to make it official, if I just need to keep patching CC and BBB as they get updated, or if some other solution happens eventually... :)

Edit: Though he did say that it would be added to the next version of BBB here (http://kolmafia.us/showthread.php?1240-Best-Between-Battle-Script-Ever-formerly-AutoMCD&p=39468&viewfull=1#post39468)...

Locus
02-02-2011, 05:13 AM
I'm not sure why but the script got me a pirate juice today. In the log it said pirate juice was going for 45k and that's why it got one; however, in the mall there is 8 pirate juices for less than 45k. It looks like it took the price of the store above the limit 1 and got it based on that. The other pirate juices weren't added after I got mine as a sr because I checked right after it said they were selling for 45k and there was 8 below it then too. I'm not sure what happened or if it's anything fixable.

Bale
02-02-2011, 05:30 AM
Not fixable. It's a basic limit of KoLmafia's restriction in price information. It will only check price once per day. If the price drops after that, there is no way for this script to adapt even if time has passed.

Aankhen
02-02-2011, 01:41 PM
The check for a CLI command breaks things with counter names that are less than three characters long. I fixed this by changing line 686 to:

if((name.length() >= 3) && (name.substring(0, 3) == "cli")) {
(I use counters for YRs, so I came up against this pretty often, and finally checked the code today.)

tgetgel
02-02-2011, 02:24 PM
Bale, thanks for the script.

A feature request - while in HC, the selling price of an SR is a moot point (unless you are using them to build up your meat reserves after freeing the king). More important, in my mind, is what the SR can do for you at your level or in the next couple of days whilst in HC. Can we have a section that says - if in HC and level X or lower that these are the SR's we will go for, when between level X and Y (maybe if these quests are not completed) we go for these, between level Y and Z go for these, and above level Z go for them all?

It just seems to me that the lunchbox is useful early on in HC for the adv. The scented oil is useful as a combat restore. The Dogsgotnonoz pills are useful for the stench resistance (only get one?) (or the other sublime elemental resistances).

Another option is to limit SR collection in HC to one of some SR's and X of others. Maybe prioritize them based on level? I know that not everyone's game play style is the same. Even the class might effect the choice. But choosing purely on selling price whilst in HC is not the optimum, but then, what script is optimal!

slyz
02-02-2011, 02:34 PM
This will be taken care of:

Now that I've finished this essential update, my next step is to start working on a way for the users to list the semi-rares they want to get in hardcore so that it can try to get any of which the character has less than 1.

tgetgel
02-02-2011, 10:08 PM
Thanks, slyz. I would like it to adjust the SR's collected in HC based on what I have and what I have done or what I need.

Bale
02-02-2011, 11:53 PM
A feature request - while in HC, the selling price of an SR is a moot point (unless you are using them to build up your meat reserves after freeing the king). More important, in my mind, is what the SR can do for you at your level or in the next couple of days whilst in HC. Can we have a section that says - if in HC and level X or lower that these are the SR's we will go for, when between level X and Y (maybe if these quests are not completed) we go for these, between level Y and Z go for these, and above level Z go for them all?

It just seems to me that the lunchbox is useful early on in HC for the adv. The scented oil is useful as a combat restore. The Dogsgotnonoz pills are useful for the stench resistance (only get one?) (or the other sublime elemental resistances).

Another option is to limit SR collection in HC to one of some SR's and X of others. Maybe prioritize them based on level? I know that not everyone's game play style is the same. Even the class might effect the choice. But choosing purely on selling price whilst in HC is not the optimum, but then, what script is optimal!

Gah! Thanks for pointing out exactly why I didn't want to implement the feature. I'd temporarily forgotten that people other than myself will have different ideas of how it should work. You've got about three different ideas for how it should work without even knowing how YOU want it done and none of them are exactly what I was thinking of doing. Maybe I'll have to rethink this idea.

shazbot
02-03-2011, 02:29 AM
I'm sorry if this is a repeat,it's been a while since I had to touch my scripts since everything was working great.

I don't know if it's CC's problem, or something else entirely, but whenever a wormwood counter triggers my autoadventuring just halts. After inspecting it, it looks like the first step for !pipe, which adventures for AbsintheMinded turns 9-7 in the Stately Pleasure Dome aborts prematurely. It does turns 9 and 8, but then it gets the halt even though one more adventure for the stately adventure.

PS. Thanks for all your contributions, Bale

Bale
02-03-2011, 04:19 AM
Is there any output in the CLI when it stops? Please copy-paste it here. At least copy-paste the last half-dozen lines from your gCLI even if it looks irrelevant to you.

Also, please type this in the CLI and copy-paste the output here:


get counterScript
get wormwood

slyz
02-03-2011, 06:55 AM
Maybe I'll have to rethink this idea.
A simple user-defined list of SRs it should get in the specified order should be enough. A list like this, for example:


lunchbox
cyclops eyedrops
ASCII
inhaler
lunchbox

If the user isn't level 9 when it's the ASCII's turn, try the next SR on the list and so on until there is one you can get, else abort.

This would mean you would need to store more data than the actual list (like the index of the next semi-rare to get). I'll have a go at it later today, if you want.

coldasice
02-03-2011, 12:24 PM
Question:

1. Can the script automate the use of Tiny Bottle of Absinthe, like it automates the use of Dance Card? I tried, but it doesn't seem to auto-use TBAs.
2. Once I load the script with the 'set counterScript = CounterChecker.ash', can I use the original mafia's counterScript? For instance, I want my automation to stop when I reach a semirare.
3. Is there a command to stop using the Dance Cards?

Awesome script though, it helped me leveling as moxie class.

Winterbay
02-03-2011, 12:59 PM
Question:

1. Can the script automate the use of Tiny Bottle of Absinthe, like it automates the use of Dance Card? I tried, but it doesn't seem to auto-use TBAs.
2. Once I load the script with the 'set counterScript = CounterChecker.ash', can I use the original mafia's counterScript? For instance, I want my automation to stop when I reach a semirare.
3. Is there a command to stop using the Dance Cards?

Awesome script though, it helped me leveling as moxie class.

1-2) Not sure.
3) If you want it to not use dance cards you use
zlib BaleCC_useDanceCards = false which will stop it from using a new one when you have encountered your waltzing matilda.

tragus
02-03-2011, 02:16 PM
Oh noez.


Request 2 of 150 (Island: Hippy Camp (Stone Age)) in progress...
Begin index 0 greater than end index -1 (CounterChecker.ash, line 52)
Fortune Cookie counter expired. Last semirare found 547 turns ago (on turn 5071) in Limerick Dungeon

In case you care:

> get counterScript

CounterChecker.ash

> get wormwood

!pipe

I'm running latest build as of this morning.

Winterbay
02-03-2011, 02:32 PM
I think it would be more interesting if you did
ash get_property("unlockedLocations") and post that since that is what is on that line :)

tgetgel
02-03-2011, 03:27 PM
Gah! Thanks for pointing out exactly why I didn't want to implement the feature. I'd temporarily forgotten that people other than myself will have different ideas of how it should work. You've got about three different ideas for how it should work without even knowing how YOU want it done and none of them are exactly what I was thinking of doing. Maybe I'll have to rethink this idea.

Bale,

What were you thinking about doing for your approach? Maybe we can come to a consensus approach that might not be optimal, but workable.

tragus
02-03-2011, 06:41 PM
@Winterbay, I'm not to whom you were referring, but for my Oh Noez bug report:

> ash get_property("unlockedLocations")

Returned: Post-War Sonofa Beach,Post-War Junkyard,The Middle Chamber,Hippy Camp (Stone Age),Haunted Wine Cellar (Southeast),Haunted Wine Cellar (Southwest),Haunted Wine Cellar (Northeast),Haunted Wine Cellar (Northwest),Haunted Wine Cellar (automatic),The Mer-Kin Outpost,The Wreck of the Edgar Fitzsimmons,The Dive Bar,The Marinara Trench,Anemone Mine,Madness Reef,An Octopus's Garden,The Briniest Deepests,The Brinier Deepers,The Upper Chamber,The Briny Deeps,Hole in the Sky

version

KoLmafia v14.4 r9000

(and yes, CC 1.492; and no, I didn't look into the CC code before reporting)

Winterbay
02-03-2011, 06:46 PM
@Winterbay, I'm not to whom you were referring, but for my Oh Noez bug report:

> ash get_property("unlockedLocations")

Returned: Post-War Sonofa Beach,Post-War Junkyard,The Middle Chamber,Hippy Camp (Stone Age),Haunted Wine Cellar (Southeast),Haunted Wine Cellar (Southwest),Haunted Wine Cellar (Northeast),Haunted Wine Cellar (Northwest),Haunted Wine Cellar (automatic),The Mer-Kin Outpost,The Wreck of the Edgar Fitzsimmons,The Dive Bar,The Marinara Trench,Anemone Mine,Madness Reef,An Octopus's Garden,The Briniest Deepests,The Brinier Deepers,The Upper Chamber,The Briny Deeps,Hole in the Sky

version

KoLmafia v14.4 r9000

(and yes, CC 1.492)

Actually, it was to you since your error contained line 52 which checks unlockedLocations and it seemed to me from the error that the string was empty, but it appears to not be so I'm out of ideas. I'll thus leave that error to more competent persons :)