BatBrain -- a central nervous system for consult scripts

If things are working as they should haveing unkown_ml at anythign other than 0 should use that value for your unkown monster. Mine seems to be doing that so I wonder why it doesn't for everyone...
 
Next time you fight one, cancel out of the fight and check monster_attack or whatever else is unspaded. Validate what, exactly, it's set to, and note your MCD if set as well. Check in BatBrain to see what it has for substituting unknown_ml... at last check, it was having 0 for the stats in BatBrain, but on my testing, the monsters had a 1 instead during combat. If this is the case for you as well, you may need to either replace the 0 with 1, and expect it to be wrong when dealing with the first few weak monsters, or do one of your other options...
 
I just updated the plural monsters file with information on the swarms of ghoul whelps and bees. The flock of seagulls are listed as a group monster by the wiki but says nowhere how big the group is so I left that one out.
 
Double posting, but since it's a completely different matter I think it's warranted.
I ran into the naughty sorority nurse today. She is stated in batbrain.ash ot have no attack so m_dpr which calls m_even which calls m_regular returns 0 which means that die_rounds will get a division by 0 error.
I changed die_rounds to the following:
Code:
int die_rounds()	// how many rounds at the current ML and stun until you die
{	//naughty sorority nurse and quiet healer have no attack
	return ($monsters[naughty sorority nurse, quiet healer] contains m ? 999999 : ceil(my_stat("hp") / m_dpr(0,-adj.stun)) + adj.stun);
}

Which I think will avoid that problem.
 
I guess that could work as well, and also be more general in case there are any other cases where m_dpr turns out to be 0.
 
I already mentioned that I'd be fixing that silly division by 0 error.

unknown_ml is currently working correctly for unknown stats, but not unknown monsters. It is a little bit broken for the defense stat with +9 or higher ML, as I mentioned previously, but a fix for that is already in my local copy and will be in the next update.

That leaves unknown monsters. I found unknown monsters (tested on my shadow, since mafia doesn't ambiguate those yet) also had stats of 1, making them completely indistinguishable at runtime from known monsters with stats of 1. (And thus unknown_ml can't behave as desired.)

It would be far more useful if they had stats of 0, since this is what other unknown stats are in mafia's monster data. I think we can submit this as a feature request to make detecting unknown monsters possible. And for consistency. I'll do that soonish unless someone (like Bale perhaps) beats me to it. Right now I'm attempting to repair my laptop myself -- it is in pieces all over my table at the moment. Next step: attempting to rework a GPU chip using a hair dryer and an infrared thermometer. Exciting times.
 
That would take changing the Math.max( 1, <calculation> ) on each set to have 0 instead... can in-battle attack or those actually ever start at 0 based on -ML?

For the next version of BatBrain, could the 'meat-symbol' be changed from the actual symbol to µ so that it's actually portable between systems?
 
Last edited:
Originally did that, it printed as "μ" on this Linux machine rather than the actual character. Will do entity_encode("μ") -- a bit of a pain, but will work everywhere.
 
On my system it kept showing up as a rather funny box and some other symbol as well. Not so much of a problem, but looks odd.
 
I'm guessing that having the symbol in is also why, every time I edit BatBrain with a standard text editor (Notepad), it adds 3 non-printing characters to the start of the file that have to be removed with a hex editor before mafia can parse it again.

Edit: Any way to have kill_rounds combine damage and hit chance? I split out a version that does dmg_dealt(regular(1)) * hitchance(1) inside, but if there were an official way to do this, it would be more accurate for monsters that you can easily kill if you'd ever hit them...
 
It would be far more useful if they had stats of 0, since this is what other unknown stats are in mafia's monster data. I think we can submit this as a feature request to make detecting unknown monsters possible. And for consistency. I'll do that soonish unless someone (like Bale perhaps) beats me to it.

Sure. I'll take care of that for you. I'm pretty sure that this counts as a bug, not a feature request since it is not operating as intended.
 
Last edited:
That was FAST! Unknown monster issue fixed in Revision 9427, thanks to Velocity Veracity.


Addendum: Yeah, it's only been 2 hours since my last post in this thread so I'm double-posting. I'm a minion so I can decide when new posting is relevant enough to break the rules. :P
 
Last edited:
Another bug... hitchance can go negative, which does bizarre things to some of the other calculations. I've replaced the following line:
Code:
   return minmax((6.0 + attack - max(monster_stat("def"),0.0))/10.5,0.0,1.0) - fumble_chance();  // change minimum to critchance
with this:
Code:
   return max(((9+numeric_modifier("Critical Hit Percent"))*(numeric_modifier("Critical")+1)/100), minmax((6.0 + attack - max(monster_stat("def"),0.0))/10.5,0.0,1.0) - fumble_chance());  // change minimum to critchance

Basically, take the higher of critchance or the actual calculation... I believe that the critchance is correct. It starts with a 9% chance + percentage modifiers, multiplied by 1+critical multipliers, divided by 100 to provide just a percentage chance.

Might be better to do that as a separate function though... critical_chance... Let me work that up.

Edit: Have these showing like this now:
> ash import <batbrain> hitchance(1)

Returned: 1.0

> ash import <batbrain> critical_chance()

Returned: 0.09

> ash import <batbrain> fumble_chance()

Returned: 0.045454547
This is just below fumbles, since I thought they were related... anything similar to Dr. Awkward's fumble code probably needs to be added. At the very least, Dr. Awkward probably forces critical chance to 0.
Code:
// ======= CRITICALS =======
float critical_chance() {
   return (9+numeric_modifier("Critical Hit Percent"))*(numeric_modifier("Critical")+1)/100;
}
I've replaced the line above with this, which should hopefully be more accurate...
Code:
   return minmax((6.0 + attack - max(monster_stat("def"),0.0))/10.5 + critical_chance() - fumble_chance(),0.0,1.0);  // change minimum to critchance
After deciding if it will hit or miss with normal chances, add the chance of a critical hit, subtract fumbles... though this might be better?
Code:
   return minmax((6.0 + attack - max(monster_stat("def"),0.0))/10.5 + critical_chance() - fumble_chance(),critical_chance(),1.0-fumble_chance());  // change minimum to critchance
Since your lowest chance to hit should be only getting criticals, and your highest chance to hit shouldn't be higher than your chance of fumbling...
 
Last edited:
Isn't it just enough to move the fumble_chance() part into the minmax-statement? I mean unless fumble_chance() = 0 there is no way I am going to reach 1.0 in hitchance anyway...
 
That's why my max in the lower ones is 1.0-fumble_chance(), and the min is critical_chance(). :) It does have +critical_chance()-fumble_chance() in the actual section being compared, but I put them as boundaries as well.

Edit: Winterbay found a case where the scaling HP on a bee was set to his MCD level, so BatBrain decided that it was an unknown monster despite it being properly set. This is due to the unknown monster detection code matching on monster none, stat 0, or stat MCD. However, since Veracity's awesome change, this is no longer the case... it's only ever stat 0 now.
> current_mcd

Returned: 10

> monster_attack

Returned: 0
That would be the swarm of ghuol whelps with no data on them returning 0 for all stat-checks. This means we should just be able to use this for the unknown checks:
Code:
   if (monster_attack(m) == 0)
      adj.att = to_int(vars["unknown_ml"]);
   if (monster_defense(m) == 0)
      adj.def = to_int(vars["unknown_ml"]);
   if (monster_hp(m) == 0)
      adj.dmg[$element[none]] = to_int(vars["unknown_ml"]);
 
Last edited:
I said it the last time and I will say it again ... those fixes are all wrong.

Looking over the wiki page for hit chance (<- link):

baserate = ((6+attack-defense)/10.5), minimum 0 maximum 1
fumble chance = fumbrate
normal hit = (1-fumbrate)*(baserate-critrate)
critical hit = (baserate) or (critrate), whichever is lesser
miss = (1-fumbrate)*(1-baserate)

This is obvisouly wrong, since it would mean you can't hit with criticals if you can't hit without them. "critical hits are a fixed percentage of all non-fumble attack attempts" actually means that it's
normal hit = (1-fumbrate)*(1-critrate)*baserate
critical hit = (1-fumbrate)*critrate
miss = 1 - normal hit - critical hit
hit = (1-fumbrate)*( critrate + (1-critrate)*baserate )



So, with Theraze's function definition(s) ..
Code:
  float baserate = minmax (6.0 + attack - max(monster_stat("def"),0.0))/10.5, 0, 1);
  float critrate = critical_chance();
  return  (1-fumble_chance())*( critrate + (1-critrate)*baserate );
 
I believe 10.5 in the denominator should be an 11, the wiki is incorrect. [1]

I notice that you just posted this on the discussion page there; right above your post there seems to be some discussion of why they didn't correct the value to 11. I still don't quite understand why after reading it.
 
Sounds good to me. Implemented into my copy of BatBrain. :) Little tweak... needs another left parenthesis before the 6.0 on the baserate.
 
Back
Top