BatBrain -- a central nervous system for consult scripts

Winterbay

Active member
A little error I found when I got the "[FONT=Arial,Helvetica]Curse of Vulnerability[/FONT]": Can't take square root of a negative value (BatBrain.ash, line 628)

I guess a min or max is needed somewhere.
[FONT=Arial,Helvetica][/FONT]
 

Winterbay

Active member
Yeah, I put max(1, DA) in mine beacuse I wasn't sure if KoL went to 0 or not and though that that difference wouldn't matter anyway.
 

heeheehee

Developer
Staff member
No, you don't want to treat -500 DA as 500 DA. Probably want to use max(0, DA) for now.

Okay, tested and it is indeed max(0, DA).

(for what it's worth: spunky princess was doing 119-123 damage (out of 30 trials) to a character with 0 DA, 0 DR, 1 moxie. This also suggests that negative DR does nothing.
 

zarqon

Well-known member
Forewarning!

I'm getting increasingly excited about the upcoming release of BatBrain. It is going to provide a fantastic new mechanic for custom actions. Custom actions will be flaggable with an action category in batfactors, e.g. "custom attract" or "custom banish 10". Then, calling scripts will be able to simply choose the best action from opts[] which matches the given category for whichever custom purpose you have in mind.

Much more to say, but will say it in the release post. The reason for this announcement is that, as part of adding this functionality, I'm renaming the "ftf_" settings to "BatMan_" settings:

ftf_olfact will become BatMan_attract
ftf_grin will become BatMan_banish
ftf_yellow will become BatMan_yellow

I've already added some temporary code to ZLib which will ease this transition, so your settings will migrate over to the new names, and the old settings will be deleted, with no hassle. However, any script authors who are accessing any of these settings in their scripts may now consider themselves forewarned that I am about to break their scripts. I apologize, but I believe renaming them is worth it, since the alternative would be a progressively more confusing group of settings, as their names describe their purpose less and less well.
 

Bale

Minion
I welcome the new settings names. I actually deleted them once because I assumed that I wasn't using settings for a script that I haven't used in over a year. And your point about the names becoming less relevant is quite well taken.
 

zarqon

Well-known member
r18 Update!

Since the number 18 sounds kind of like a curse word in Korean, I'm going to swear in this post!

Me: Post, do you solemnly swear to contain the awesome updates in r18?
Post: I do.

Cool, post sworn in! Now, for the updates, and they are many and awesome:

The big change -- which just broke WHAM until Winterbay fixes it -- is that the custom field is now a string. You won't fully realize how awesome this is until SS updates, but when it does, prepare to be pleased. We can now not only specify custom actions in batfactors, we can also append a category after the custom keyword for actions which provide a similar custom mechanic. So far, the categories SS is going to support are: attract, banish, yellow, copy, and runaway. Then, when you want to banish a monster, you'll be able to -- oh, what's this? A new custom_action(type) function in BatBrain? And it returns the most profitable action in a given custom category? So wait -- if I had specified some monsters to attract in BatMan_attract, and SS encountered one of those monsters, it would Olfact that monster OR jiggle the cream staff if I was in AoJ? Fantastic! Or if I had specified certain monsters in BatMan_banish, SS could use this function to choose the cheapest banishing option and banish the specified monster with a banishing skill or item? Oh my goodness! 18!!

Another very cool feature that happened as a result of this process is that BatBrain now adds informational counters whenever you banish a monster with a temporary banishment, such as a crystal skull. The counter shows the item or skill you used to banish the monster, and contains the name of the monster, plus "banished". It is set to the number of banished rounds specified in batfactors for the action. So it is now possible to detect with great accuracy whether or not a monster is currently banished. In fact, look at this nifty function from the upcoming BatMan RE release:

PHP:
boolean is_banished(monster m) {
   if (m == $monster[none] || m.boss) return false;
   if (m == to_monster(get_property("_nanorhinoBanishedMonster"))) return true;
   switch (my_class()) {
      case $class[avatar of boris]:
      case $class[zombie master]: foreach i,s in split_string(get_property("banishingShoutMonsters"),"\\|") if (m == to_monster(s)) return true; break;
      case $class[avatar of jarlsberg]: foreach i,s in split_string(get_property("_jiggleCheesedMonsters"),"\\|") if (m == to_monster(s)) return true; break;
   }
   if (get_counters(m+" banished",0,20) != "") return true;
   return false;
}

It's going to use that function to dim banished monsters in the combat queue. But I'm getting ahead of myself! Eighteenit!

As mentioned previously, the autoresponses for Colosseum monsters are mostly working. It's still not safe to fully automate combat against monsters there, however, since the script may use your Mer-kin skills as a normal combat action, preventing that skill from being available later as an autoresponse. But combats in BatMan RE were working nicely. The macro section is also not fully finished, as I haven't yet made the macro loop on itself, or whatever it has to do there. So it only macrofies the first autoresponse, and all the following autoresponses are single server hits. Once I add Mer-kin weapon skills to the temp blacklist when in the Colosseum and fix the macro, that will be all done and we will be able to completely automate that zone.

And now for a significant pile of smaller but not unimportant fixes!

  • More vprints() for better debugging. Now when there's a formula error, verbosity 9 will let you narrow it down to which line in batfactors contains the error.
  • Slightly faster matcher in to_event(), allows us to ditch two contains_text() calls. Sonofaneighteen!
  • Refactored the loading of batfactors to fix several order-of-operations errors! Since we're now loading monster information from batfactors, we can't normalize the damage types (which calls dmg_dealt(), which needs to know monster resistances) until after we've set the monster. However, we can't set the monster until after we load batfactors. So I split the batfactors loading and parsing into two separate functions, and call them both from within set_monster(), towards the beginning and end of the function, respectively. This means several excellent things:
    1. BatBrain can now be used predictively outside of combat, sequentially simulating combats for a series of monsters, as batfactors itself is completely reloaded when you set the monster.
    2. Sauceror skills with Immaculate Seasoning now properly choose an element.
    3. "perfect" damage now correctly chooses an element. You get the picture.
  • Related to the above fixing of tuning damage, I let BatBrain know about a few heretofore unknown pieces of equipment which also tune damage: the slime-covered staff, The Necbromancer's stein, and the Wand of Oscus.
  • Fixed another OoP error: Calculation of poison danger was being performed in set_monster(), calling attack_action(), before opts[] was even populated. So now we calculate poison danger in build_options().
  • Cap DA and DR on the low end at 0.

Enjoy, you eighteening eighteeners!
 
Last edited:

Winterbay

Active member
The big change -- which just broke WHAM until Winterbay fixes it -- is that the custom field is now a string. You won't fully realize how awesome this is until SS updates, but when it does, prepare to be pleased. We can now not only specify custom actions in batfactors, we can also append a category after the custom keyword for actions which provide a similar custom mechanic. So far, the categories SS is going to support are: attract, banish, yellow, copy, and runaway. Then, when you want to banish a monster, you'll be able to -- oh, what's this? A new custom_action(type) function in BatBrain? And it returns the most profitable action in a given custom category? So wait -- if I had specified some monsters to attract in BatMan_attract, and SS encountered one of those monsters, it would Olfact that monster OR jiggle the cream staff if I was in AoJ? Fantastic! Or if I had specified certain monsters in BatMan_banish, SS could use this function to choose the cheapest banishing option and banish the specified monster with a banishing skill or item? Oh my goodness! 18!!

A question about this (before I change WHAM to use this instead of a hardcoded list): Will this take into account the fact that you cannot banish a monster with the AoJ-staff after you've done it 5 times already?
 

Bale

Minion
Mafia uses banishingShoutMonsters for that.

To be more informative, banishingShoutMonsters is used for both "Howl of the Alpha" and "Banishing Shout." Since they both work the same way and it is impossible to have both skills it seemed like a good idea at the time. There's a decent chance that if a future class path has a similar power it will re-use the preference also.
 

zarqon

Well-known member
r19 Update

I feel that "swear in this post" is one of the best stupid puns I've generated in months, so I'm not going to try to top that. Instead I'll point out that 19 is the number of this update, and it's also the number of Transcendent Olfaction, which is now included in opts as a custom action of the "attract" category.

In fact, as I was running my diagnostic script today that tells me about missing items and skills, I realized that with the new custom categories, many of them can be added. So, I added 56 combat items and 8 combat skills to batfactors which had not previously been there. Now, the only combat items missing from batfactors are pogs and two of the very brand new items which don't even have use text yet on the Wiki.

Some highlights regarding the added actions:
  • Unleash Nanites now correctly recognizes what will happen when you release the nanites and is correctly categorized as "yellow" or "banish" when appropriate.
  • Some of the fantastic reusable boss drops from Dreadsylvania are now likely to be chosen by BatBrain.
  • pulled taffy is now mostly known to BatBrain.
  • All three monster-copying items used by SS are now correctly filtered in build_items(), so if they appear in opts, you are able to copy a monster using them.
  • The new Dreadsylvania skills are added to the extent that the Wiki understands them.
  • The combat items that drop in KOLHS have also been added.

Also in this major data update process to batfactors I made a few changes to the keywords available in batfactors:
  • The "prismatic" keyword for damage types was just shorthand for "hot,cold,spooky,sleaze,stench" -- in fact the script actually replaced it like that before parsing the damage -- and with the reordering of code flow in r18 was causing problems. I opted to eliminate the keyword rather than add another foreach-factors-replace. People adding data shouldn't really mind typing those extra words so much, since it's pretty easy to copy paste.
  • A new keyword "quick" now indicates that an action does not take a combat round. Several of the new Dreadsylvania skills have this flag.

A couple more fabulous tweaks:
I made the changes I mentioned last time that needed to be done for Colosseum autoresponses. Mer-kin weapon skills are now automatically temporarily blacklisted in the Colosseum. Autoresponses in act() will now not fire for skills you haven't learned. Autoresponses in batround() are enclosed in a while loop which ought to make them autorespond until the monster does not perform a special action. These changes are untested, confirmation that they work appreciated; otherwise I'll check it out when I dive next run.

Lastly, a tweak for Winterbay: Yes. As of this update, the jiggle event for 5/day chefstaves is "custom" until the relevant property shows 5 uses -- at which point it becomes a regular action (behavior changed accordingly) and may be chosen in regular automation. I'm rather proud of that one.

Please enjoy this update! This update finally paves the way for a SS which simply uses custom_action() to enqueue attract, banish, yellow, or copy actions! So that's next.

@lost, Bale: thanks! Function works as posted then. Excellent.
 

fronobulax

Developer
Staff member
r19 Update

I feel that "swear in this post" is one of the best stupid puns I've generated in months, so I'm not going to try to top that.

And silence from the audience is often a response of admiration for such puns.

Now, the only combat items missing from batfactors are pogs and two of the very brand new items which don't even have use text yet on the Wiki.

What do you need to know about pogs? I may have some around I would donate to a good cause. For Science!
 

Winterbay

Active member
Zarqon: Am I correct when I think that when calling reset queue the monster element is not reset? (say if WHAM tries to through a double ice shard and then backs out and tries something different. Will the monster now be cold or not?
 

zarqon

Well-known member
@Winterbay: I believe you are correct, the outcome of certain happenings is not undone. Undoing that one would mean caching the monster's old resistances first, unless we want to reload the monster from batfactors each time (we don't). Have to give that some thought.

What do you need to know about pogs?

I don't think I need to know anything about them. People collect pogs, not use them. :)

Kidding aside though, those things interact with each other in complicated ways (and with ongoing effects, something BatBrain currently doesn't handle). It would be a headache-inducing nightmare to add support for them, and I rather doubt that anyone will feel their absence. The completionist in me gets a bit upset about that, but I usually tell him "What are you doing in there, completionist? Get out of there."
 

Winterbay

Active member
Couldn't you check if the currently stored element is different from what Mafia thinks and if so reset it to what Mafia thinks? That should at least handle the aligned monsters, even though I guess special monster might still be left out but there are fewer of those.
 

heeheehee

Developer
Staff member
There's currently no way to extract Mafia knowledge about physically resistant monsters short of parsing monsters.txt. I ran into this earlier today. In fact, I think I'm going to make this a feature request.
 

Theraze

Active member
Is the pinch ghost vulnerability any more complicated than undead with physical resistance? I know that the chalkdust wraith is vulnerable to this, since I've done it a few times when the character happened to have pinch ghost HP but no properly tuned elemental. BatBrain estimated it at 1 damage, but it killed it in one hit...
 
Top