Terrarium Percentages

Sentrion

Member
Overview:
I made this mainly to make tourguide runs easier. This script will append percentages after each familiar in your terrarium - the first percentage is for your current run, and the second is for your lifetime. Anything at 0.0% will not be displayed.

In addition, it will find the familiar you've used most during the current run, and will show the percentage in color - red for <90%, orange for <91%, dark green for >91%, and bright green for 100%.

In order for the relay script to work properly, you must run Tourguide.ash when you ascend (it should be easily importable into any pre- or post-ascension script). Without this, it will never display in-run statistics, but will still show lifetime percentages.

In case you're wondering, it calculates based on number of kills alone (correct me if I'm mistaken, but that is the only accurate way to measure percentages). Basically, Tourguide.ash will write number of kills to a file, and the relay script will subtract current number of kills from what's found in the file to find the number of combats any given familiar has been in during the current run.

Instructions:
Put Tourguide.ash into your scripts folder, and familiar.ash into your relay folder. Run Tourguide.ash at the beginning of any ascension (or the end of the previous one). To account for free runaways, also run Tourguide.ash every time you log out during the run. Enjoy!

Screenshot:
http://i52.tinypic.com/allq2a.jpg

If you have any suggestions or problems, let me know, and I'll see what I can do.

Update: I just finished a run using my script (unfortunately, I didn't use it upon logout everyday, because I tend to leave mafia running all day long and into rollover - however, I didn't use many runaways, either, so it shouldn't have mattered much). The run clocked in as 91.9% on KoL, and 91.22% from my script.

Disclaimer: The code is ugly. Very ugly and inefficient. I'm not a programmer at all, so I write mostly by trial and error, and once something's working, I hate to go back and modify it, so I tend to add more lines rather than reorganizing old ones. My apologies if this irks you.
 

Attachments

  • Tourguide 0.9.ash
    3 KB · Views: 70
  • familiar.ash
    3.9 KB · Views: 69
Last edited:

Fluxxdog

Active member
Interesting. I got one tip for you because this script can fail once we have familiars numbering over 300. Gonna take a while but... Anyway check this out. Instead of:
Code:
[COLOR="Red"]for i from 1 to 300[/COLOR]
{
	string locater;
	string fam = to_string([COLOR="Red"]to_familiar(i)[/COLOR]);
...you can keep the script up to date with:
Code:
[COLOR="Red"]foreach critter in $familiars[][/COLOR]
{
	string locater;
	string fam = to_string([COLOR="Red"]critter[/COLOR]);
This will go through every familiar in the book like you want, but skip over numbers where familiars don't exist, like 13, 64, etc.

$familiars is a special data type that includes every familiar, meaning you only get real data. foreach will go through each one appropriately, one by one, like your for statement does. And this way, should the number of familiars get to 1000 (yeah right, but still), it'll still count them without having to tweak you script.

Notice: It always does when you start out, but then you learn by asking and experimenting and taking critique.
 

Sentrion

Member
Thanks! For some idiotic reason, I was under the impression that $familiars wouldn't work. I..don't know why. I've updated both scripts.
 
Also, at some point, someone will breach 999,999 kills.
Consider the regex:
" (\d[\d,]*) kills"
Will grab the number regardless of character length.
 

lostcalpolydude

Developer
Staff member
There is no guaranteed way to check familiar percentage. If you start a fight and then run away, or lose, that turn counts for the familiar without changing any value that you can check. This is why you can't use bander runaways in a 100% run.
 

xKiv

Active member
Unless it's a 100% bander run, of course.

Is there any way to ask mafia how many combats it has seen in this ascension? Then the difference between that and total familiar kills in this ascension could be used to conservatively estimate the percentages (yes, it's possible you have 90% with this familiar, but it's also possible you have only 88% with it, so go and pad your run with 200 more adventures to be sure!)

Does this script tell me how many more combats I would need to spend with a familiar to make it my 90% familiar?
Does it round safely? I normally use ascension log visualizer, but that tells me "90%" even if it is actually 89.6%, which KoL doesn't recognize as 90% ...
 

Sentrion

Member
There is no guaranteed way to check familiar percentage. If you start a fight and then run away, or lose, that turn counts for the familiar without changing any value that you can check. This is why you can't use bander runaways in a 100% run.
I'd wondered about runaways. I suppose I could modify the script to work as/in a logout script, if anybody is interested. That way, I could check daily runaways and add those in.

Does this script tell me how many more combats I would need to spend with a familiar to make it my 90% familiar?
Does it round safely? I normally use ascension log visualizer, but that tells me "90%" even if it is actually 89.6%, which KoL doesn't recognize as 90% ...
It doesn't, but I think I can add that in later. As for rounding, that is..somewhat uncertain. I'd have to play around with it some to see what kind of margin of error it has. I certainly wouldn't trust it to be 100% accurate in any case.

Thanks for the info/queries. I should probably add version information at some point.
 
I'd wondered about runaways. I suppose I could modify the script to work as/in a logout script, if anybody is interested. That way, I could check daily runaways and add those in.
Huh, I wasn't aware there was an easy runaway counter available to ASH.. I suppose it's a get_property kinda deal. Useful!

As for rounding, that is..somewhat uncertain. I'd have to play around with it some to see what kind of margin of error it has. I certainly wouldn't trust it to be 100% accurate in any case.

Judging from the math, your script should be accurate to two decimal places... so unless your familiar is somehow wedged in [89.995,90), I think you should be safe.
 

lostcalpolydude

Developer
Staff member
I think you would need a mood to do stuff after every adventure. The most sensible place would actually be a betweenBattleScript, but those don't run during manual adventuring. Check the lastEncounter property (or maybe something else), and if it corresponds to a combat then add 1 to the turns spent for your current familiar. That sounds like a complete rewrite of the script, though.
 

Sentrion

Member
Yeah, I think it'd be simpler to just ignore defeats, and make sure everyone's aware of the probable discrepancies the script shows.

On another note, I found a problem that doesn't seem to originate from any of the code in my script. When I go to rename a familiar, any spaces in the name will turn into plus signs. This happens even in a clean script with a write(buffer) command passing the original page through unchanged. Is this a known problem? Any fixes?
 

Fluxxdog

Active member
Actually, I think it is the script. i had the same problem with a relay script that put up a notice on how to give yourself reminders, but whenever I went to save notes, it put + in place of spaces and other characters became %28 or the like. Once I got rid of the relay script, it worked perfectly fine again.
 
If it happens even with just a simple write(visit_url()) then the problem is clearly in the way mafia is handling something. Post a bug report.
 

Veracity

Developer
Staff member
Revision 8785 should fix the URL encoding issue: when setting up the relay request for use by relay override scripts, we copied the URL from the original script and URL encoded it again. We also turned any GET requests into POST requests, which probably nobody noticed, since KoL only expects/requires GET in a tiny handful of places. Both issues should be fixed now.
 

Sentrion

Member
The arbitrarily-numbered Tourguide 0.9.ash has been released. For best results, it should be called at the beginning of an ascension as well as upon logout every day. The relay script has also been updated. If your tourguide familiar (automatically assumed to be the most-used fam of the run) is the active familiar, it will display a "Tourguide status" showing how many combats you need in order to reach 90% from either direction - i.e., if you're under 90%, it will display the number of combats you need before qualifying for a tourguide run again, and if you're above 90%, it will display how many combats you can "spare" using a different familiar.

As for how accurate the math is, all I've discovered is that the hundredths place always rounds down (because I truncate anything after that).
 
Last edited:
Top