Universal Recovery Script

shoptroll

Member
Bale,

I might have an interesting log for you to look at. I just caught the script/Mafia in an infinite loop where it was alternating between Travoltan Trousers and Sugar Shorts and kept using Doc Galaktik's consumables to try and get me back to 100% health (min value is 10%, also I have cocoon). This was while using the autoDungeon script for the first time so I'm not sure if there's a weird conflict that I'm unaware of.
 
Last edited:

Bale

Minion
That is a massively weird edge-case! Why would anyone use Doc Galaktik's consumables in aftercore anyway? I guess you turned off mall purchasing, while using NPC store purchasing?
 

Theraze

Active member
Nope... you're just buying exactly enough to get to 100%, despite the fact that wearing the trousers drops your health because of muscle... Fix for it is to not try to restore to 100%. For now, at least. There was a long thread-series on this... it's due to the way that mafia handles restoration and that it passes the amount to heal once, not taking into account if buying the item for restoration will make you require more total restoration.
 

Bale

Minion
While you are correct Theraze, it is still an error that Universal Recovery does not handle that gracefully, or at least fail gracefully. Infinite loops are very bad form.
 

shoptroll

Member
That is a massively weird edge-case! Why would anyone use Doc Galaktik's consumables in aftercore anyway? I guess you turned off mall purchasing, while using NPC store purchasing?

I'll check my settings in a little bit and let you know. Does mall purchasing rely on mafia's mall purchasing? I think I might have told mafia not to buy from mall stores at some point.
 

Theraze

Active member
I think when it was discussed earlier, it was listed as a mafia issue, not as a URS issue... Though I suppose you can script around it if you set your target initially, and recheck how much it will need to heal to get there immediately BEFORE the healing begins, but after it's purchased restoratives... it shouldn't damage much more (unless it involves folding) to go buy more.
 

shoptroll

Member
Here's the log extract. Unfortunately I've turned down Mafia's logging so there's probably not a ton of detail but you can see what happened :\
 

Attachments

  • mafia_urs_edge_condition.txt
    65.4 KB · Views: 57

Theraze

Active member
Getting this with each character, first adventure today:
Checking for updates (running ZLib ver. : 22)...
_version_zlib => : 22
You have a current version of ZLib.
Checking for updates (running Best Between Battle Script Ever ver. 2.2)...
_version_automcd => 2.2
You have a current version of Best Between Battle Script Ever.
map_use_for_items.txt => 2009-12-31T23:06:36-06:00, checked 20110127
You have the latest use_for_items.txt. Will not check again today.
Updating recoveryScript_map_v2.txt from '2009-11-19T03:48:59-06:00' to '2011-01-26T04:20:20-06:00'...
recoveryScript_map_v2.txt => 2011-01-26T04:20:20-06:00
...recoveryScript_map_v2.txt updated.
_meatpermp => 1.5000001E-5
_meatperhp => 0.0010
_version_BalesUniversalRecovery => 3.78
Map modified within foreach (Universal_recovery.ash, line 1497)
After I abort (press escape) and start again, it works fine.
 

slyz

Developer
Code:
item null = $item[Xlyinia's notebook];
item reserve = null;

(...)

// Try to be frugal and consider on-hand reserve if in hardcore/ronin.
foreach key, value in heal {
	if(item_amount(key) > 0 && value.minmp > heal[reserve].minmp && value.combat == true)
		reserve = key;
}
On the first run of the day, the heal map contains the info hosted on Z's server. The fresh heal map does not contain a "Xlyinia's notebook" key (since it overwrites the one modified by restore_values()).

When running reserve_healing() for the first time, looking up heal[reserve].minmp will cause the error.
 

Bale

Minion
OH!

The beer-scented teddy bear is a new healing item just added to the game. Since I just updated the restore map on z's server yesterday it triggered this bug today! (Actually, I need to remove that since I just realized I can screw up the quest and I don't have any checks for it in yet.)

Obviously this bug won't pop up often since I almost never update the datafile, but I'll fix it before the next time.

Thanks slyz.
 
Last edited:

StDoodle

Minion
Haven't dug into UR's code lately, but if you don't have enough MP for Cocoon, nor meat to recover it, it's still possible to have enough meat for an herb. Could that be the case?
 

PadainFain

New member
A small issue

I found a small over-healing issue with the script...

If the script decides to heal HP with MP (e.g. tongue) and then restores the MP it doesn't consider any HP gained during restoration of the MP. When you are tight on Meat it can make a big difference to getting through the days turns. Especially when ascending at any decent pace is slow because, like me, you have very few skills!

e.g. with wrong numbers for illustrative purposes.

HP at 0, MP at 100.
Cast Tongue a few times
HP at 100, MP at 0.
Use Palm Fronds
HP at 100 (+100 wasted), MP at 100.

Is it possible to modify it so that it evaluates what it will do about MP after it does what it has chosen to do about HP and then reconsider?

I know it's possible but it may require a major rework that you don't want to do. Instead of telling the script, restore me to X HP and Y MP, you have to ask it to iteratively work it's way towards X HP and Y MP. i.e. take one step towards this goal and then call myself again for the next step. And keep calling me until my goal is reached.

Actually it may not be that much work. If you put the whole script in a function of its own but force each option to only consume one item and return, and then rewrite the main loop to manage the goal and to call that function, consuming one item at a time.

In psuedo-code:

do_action() {
evaluate_best_option()
take_one_action()
}

main() {
HP=$1, MP=$2;
while (HP < $HP && MP < $MP ) {
do_action();
}
}
 

Bale

Minion
Is it possible to modify it so that it evaluates what it will do about MP after it does what it has chosen to do about HP and then reconsider?

I've already got a bit of a work around for that problem, enough that your worst-case example is unlikely to take place. The problem is known though. It is a big deal to fix and not a high priority since my work around does do a pretty good job.
 

PadainFain

New member
A quick question...

After an adventure does KolMafia call it's recovery script with it's current HP, execute, then call it with it's current MP and execute? That appears to be the case so would it be possible to make KolMafia make a single call with both HP and MP?

Even if it's not the recovery script could do both anyway and that's something I might take a look at on a free evening.

I'm interested to know what your workaround is though?
 

Bale

Minion
You're correct about what KoLmafia does. Changing that would require a modification to KoLmafia itself and it's a pretty good behavior anyway.

My workaround is to assume that I'll need enough MP to restore HP with a skill if the character has a healing skill. It then attempts to restore a reasonable amount of MP before restoring HP. If the process of restoring MP uses items that restore HP also, like palm fronds, then it proceeds to heal only the remaining HP as normal. This is superior to the pre-workaround version since it sucks to use palm fronds after HP was maxed out.
 

PadainFain

New member
Yeah, I figured that was it from reading the script after I posted. Looks like it'll work in pretty much every case. I just had an extreme scenario where I was adventuring as a MUS class with no skills and without safe MOX. I was having to heal every 3-4 rounds with max MP and min HP. So every time it would cast tongue repeatedly and then use Fronds. My workaround is to buy a skill and use it in combat! ;)
 
Top