BatBrain -- a central nervous system for consult scripts

The domain is, in fact, registered through GoDaddy. It loads fine for me here in Korea, but it might not for you for a while, depending on where you are, it seems.

I've been AWOL from KoL for almost two weeks, had a slew of things pop up, mostly necessary or otherwise urgent, and haven't even had time to play KoL much less script it. It's looking like Friday before I get a chance to catch up. I hear there's a whole 'nother challenge path now!

On the plus side, I just recently voice acted for my first ever animation! I got to be the raccoon, the duck, and the inflatable dinosaur.
 
Function 'sell_val( item, boolean )' undefined. This script may require a more recent version of KoLmafia and/or its supporting scripts. (BatBrain.ash, line 362)
Consult script 'SmartStasis.ash' not found.
You're on your own, partner.
Click here to continue in the relay browser.

Attempting to do the junkyard I encountered this error. I have the latest build, smart stasis and bat brain are both located in the same folder with zlib.

ETA: I downloaded the latest smart stasis/bat brain and re-ran with the same error.
 
I have no idea how to begin to figure out the why, I can click on a .ash and run it, but that's about as far as my understanding goes. And these are just support, they don't run anything. All three of Zarqon's scripts are in mafia\scripts. I don't think the location is the problem, they'd all been happy as clams in the exact same spot and functioned perfectly until today. The script I was running when I got the BatBrain error was BCA.
 
PHP:
foreach te,it,rd in factors {                 // remove placeholders, reduce ranges to averages, tune damage
  ...
}

Any chance you could save the result of this in a new map (eg. batfactors_sane.txt) and only run through it again when a change to batfactors is detected?

It would save a lot of execution time in the long run.

Edit: You're also defining string deranged(string sane) and matcher rng in each iteration, which is quite wasteful.

Edit 2: You could do it this way instead:

Code:
matcher rng = create_matcher("\\{.+?,(.+?),.+?}","");

string deranged(string sane) {
   rng.reset(sane);
   while (rng.find()) sane = sane.replace_string(rng.group(0),rng.group(1));
   return sane;
}

foreach te,it,rd in factors {                 // remove placeholders, reduce ranges to averages, tune damage
   if (contains_text(rd.special,"custom")) { remove factors[te,it]; continue; }
   factors[te,it].dmg = deranged(rd.dmg);
   factors[te,it].pdmg = deranged(rd.pdmg);
   factors[te,it].special = deranged(rd.special);
   foreach kw in $strings[prismatic,pasta,sauce,perfect] if (factors[te,it].dmg.contains_text(kw))
      factors[te,it].dmg = factors[te,it].dmg.replace_string(kw,normalize_dmgtype(kw));
   if (te == "skill") {
      if (to_skill(it) == $skill[weapon of the pastalord] && !contains_text(factors[te,it].dmg,"none"))
         factors[te,it].dmg += ",none";
   }
}
 
Last edited:
In the first post in WHAM I've uploaded a version of BatBrain modified to work with bear and zombie skills. Please feel free to take anything you want from it when you next update BatBrain :)
 
I am getting the following when running WHAM:

[952] Hole in the Sky
Encounter: The Twig and Berries
Round 0: txranger wins initiative!
> Checking for updates (running ZLib ver. r37)...
> Running ZLib version: r37 (current)
> Updating batfactors.txt from '2012-07-20T08:09:02-05:00' to '2012-10-10T01:40:49-05:00'...
> Error loading batfactors.txt from the Map Manager.
> Checking for updates (running BatBrain ver. 1.25)...
> Running BatBrain version: 1.25 (current)
> Checking for updates (running SmartStasis ver. 3.15)...
> Running SmartStasis version: 3.15 (current)
> Checking for updates (running WHAM ver. 3.6)...
> Running WHAM version: 3.6 (current)
> You have the latest pluralMonsters.txt. Will not check again today.
> WHAM: Running SmartStasis
> WHAM: Starting evaluation and performing of attack
Round 1: txranger executes a macro!
Round 1: txranger attacks!
Round 2: the twig and berries takes 241 damage.
Round 2: txranger wins the fight!
After Battle: Gorg does a few high kicks. When you're a pair of boots with no legs, the sky's the limit for how high you can kick.
You acquire an item: line
You acquire an item: star
You acquire an item: star
You gain 23 Strongness
You gain 16 Wizardliness
You gain 10 Cheek
 
The prior error (post 811) was due to loading data files from URLs being disabled accidentally. If you use the current daily mafia, it should work again.

However, daily mafia with its new awesomeness breaks current BatBrain. Replace
Code:
      case $monster[gorgolok, the infernal seal]:
with
Code:
      case $monster[gorgolok, the infernal seal (the nemesis' lair)]:
 
1.26 Update!

Hi everyone! I feel like I'm finally catching up with things in the KoL world. All the various setbacks (and by setbacks of course I mean awesome things that I chose to do instead, such as joining the pit orchestra for a musical, taking on some more teaching work, joining a Pathfinder gaming group, and reading a pile of books) meant that I'm only now starting to get to the end of my first Zombiecore run (about a month long perhaps? far too many missed days), and making BatBrain work correctly with it.

The major updates for Zombiecore:

  • BatBrain completely ignores MP for Zombie Slayers. It doesn't even evaluate the MP specified in batfactors. The only times when it considers MP are skill costs (those still cost MP) and infection (the only way to gain MP in combat). For now, BatBrain doesn't make the >50% HP calculations to determine infection success -- it simply assumes that casting Infectious Bite (specified as once-only since even though it's still available, I saw no reason anyone would ever want to cast it twice) will grant you +1 MP. And, if Infectious Bite has already happened, it also treats Plague Claws as granting +1 MP as well, which is of course not correct but may help your scripts to decide to claw if growing your horde in this way is profitable. It does filter monsters appropriately by phylum, however, so objects and plants and such will not be seen as granting MP. It's also possible to insta-zombify qualifying monsters using Bear Hug, so I added that as well. This is overall a very important change, which if accompanied by UR wising up about meatpermp, will lead to BatBrain behaving more responsibly with your horde.
  • Infectious Bite's ongoing damage is now accounted for. Augmenting this damage by Plague Claws is not yet accounted for -- the mechanic for allowing this doesn't currently exist, given that said damage can be reduced back to its starting level.
  • Thanks to Winterbay, BatBrain now includes support for Ravenous Pounce, Howl of the Alpha, Bear Hug, and Grizzly Scene. The only skill I did not steal support for was Kodiak Moment, since I haven't looked into that skill yet and his implementation was rather complex. I was away from KoL long enough that I missed that IotM entirely, so farming towards buying that, and then will test and add. I feel there might be a simpler way to implement that one, or it may well be that I end up completely stealing his work there as well. :)

Also appearing in this update:

  • Misses are now glancing blows. Woohoo!
  • When I was adding support for that, I noticed that somehow the idiot who wrote this script decided he would not factor the onhit event by hitchance, but he would factor fumbles and criticals by hitchance. That is the exact opposite of what should happen. Fixed that.
  • QWOPped Up grants clumsiness (thanks Winterbay!).
  • Skeletal scabbard doubles damage from swords.
  • Move declarations outside foreach loop for greater efficiency (thanks Catch-22!).

The only fairly serious problem I'm having now is with the Lost Glasses. I haven't yet hit on a good way to account for them -- but not accounting for them results in extremely inefficient results when wearing them as a muscle class. Part of the problem is Manuel -- when he's reporting stats, he tells you the Glasses-adjusted stat, which mafia then also faithfully reports -- but before learning them mafia reports the unadjusted stat. Since BatBrain could be called at any round number, even after other deleveling, how do I know whether mafia's stat is accounting for the Glasses or not? I can't just check monster_defense() <> monster_defense(m). Sigh. 어떡해? I dislike when KoL adds items that are complicated to account for in BatBrain -- although I must admit these items are also often some of the coolest!

Enjoy the update!

And now, some responses to previous posts:


So far, no. I look forward to the day when I am asked to provide a voice for a bat, although perhaps I will be too excited to do it properly.

Was it in English or in Korean?

English. If they wanted Korean, there are plenty of native speakers around. :)

Any chance you could save the result of this in a new map (eg. batfactors_sane.txt) and only run through it again when a change to batfactors is detected? It would save a lot of execution time in the long run.

Sadly no, since you can certainly change equipment (and thus change your elemental damage tuning) between batfactors updates. Monster elements can even change mid-combat (a la shards of double-ice). I've had the same thought -- that section always strikes me as repeating a lot of tedious work which ought to be avoidable somehow. I could see a case for a range-less batfactors, especially as no other scripts seem to be sharing batfactors and availing themselves of these ranges, which was the original reason for implementing them.

I did make the other changes you suggested. I think I somehow automatically rejected the idea of placing short-term variables at top level, and therefore decided it was much better to declare them inside some brackets where they would be indented and not-top-level, never mind the fact that the brackets belonged to a loop! Thanks for bringing that silliness to my attention.

Anyway, glad to be back! I've played my turns for today, now going to catch up (and vote) on my friend's excellent Let's Play of a highly modded Baldur's Gate.
 
The only fairly serious problem I'm having now is with the Lost Glasses. I haven't yet hit on a good way to account for them -- but not accounting for them results in extremely inefficient results when wearing them as a muscle class. Part of the problem is Manuel -- when he's reporting stats, he tells you the Glasses-adjusted stat, which mafia then also faithfully reports -- but before learning them mafia reports the unadjusted stat. Since BatBrain could be called at any round number, even after other deleveling, how do I know whether mafia's stat is accounting for the Glasses or not? I can't just check monster_defense() <> monster_defense(m). Sigh. 어떡해? I dislike when KoL adds items that are complicated to account for in BatBrain -- although I must admit these items are also often some of the coolest!

That seems like something that mafia should fix. Do The Lost Glasses reduce the initial defense by 15% or the current "effective" defense? For example, if something starts with 1000 (850) defense, would reducing its defense by 100 bring it down to 750 or 765?
 
The major updates for Zombiecore:

  • Infectious Bite's ongoing damage is now accounted for. Augmenting this damage by Plague Claws is not yet accounted for -- the mechanic for allowing this doesn't currently exist, given that said damage can be reduced back to its starting level.
  • Thanks to Winterbay, BatBrain now includes support for Ravenous Pounce, Howl of the Alpha, Bear Hug, and Grizzly Scene. The only skill I did not steal support for was Kodiak Moment, since I haven't looked into that skill yet and his implementation was rather complex. I was away from KoL long enough that I missed that IotM entirely, so farming towards buying that, and then will test and add. I feel there might be a simpler way to implement that one, or it may well be that I end up completely stealing his work there as well. :)

Thanks for updating. And I'm just happy you actually could make use of my modifications :)

That said, would it make sense to use the same technique used for Infectious Bite for Stringozzi Serpent? I guess that is slightly more complicated though due to the diminishing return of said damage over time.
If you find a better way to handle Kodiak Moment I'd be thrilled, the way I did it is somewhat hackish and based on a very limited understanding of how regular() works :)

Also, any reason why you removed the auto-hit code for the zombie skills and bear skills that auto-hit?
 
Hi everyone! I feel like I'm finally catching up with things in the KoL world.

Good to have you back and doing some updates! I'm glad you found my changes useful.

When you get the chance, I'd appreciate your feedback on this feature request. I've currently disabled the charge tracking in BBB as it was taking an extra 10 seconds per turn :(
 
During ronin, during a softcore zombie run:

[976] Battlefield (Frat Uniform)
Encounter: War Hippy Rigger
Strategy: D:\Games\KoL\ccs\Zombie.ccs [default]
Round 0: Joe Derp wins initiative!
Division by zero (BatBrain.ash, line 847)
 
The problem should go away if you get at least 1 zombie in your horde. The problem is that my_maxmp will be the same as my_mp in a zombie run and with 0 zombies both will be 0.
 
Back
Top