BatBrain -- a central nervous system for consult scripts

Aha, yes I see that now as well.

Even back before mafia handily ambiguated basement monsters, BatBrain included this check when building skills:

PHP:
      if (m == $monster[n bottles of beer on a golem] && is_spell(to_skill(sk))) continue;  // this dude blocks spells

So if it is casting spells against said golem then I'd have to guess that something is wrong with one of those checks. My first thought was that something was wrong with the first check, but Veracity has shown that to be unlikely. So perhaps something is up with the second check. Which spells is it casting? The is_spell() check looks like this:

PHP:
boolean is_spell(skill s) {
   if ($classes[pastamancer,sauceror] contains s.class) return true;
   if (s.to_int() > 27 && s.to_int() < 44) return true;   // hobopolis spells
   return ($skills[noodles of fire,saucemageddon,volcanometeor showeruption] contains s);
}

I had thought that to be comprehensive. More details, please. We can't exorcise the devil until we know them, because of course, that's where he is. In.
 
I'm going mad, trying to use this simply.
I cannot find some simple documentation on how to use BatBrain.
All I want to do is setup a macro in an consult to spam an item.
Help!
 
Anyone having an idea why my unknown_ml managed to get stuck? It was set to 89 but showed up as 300 no matter what I did until I set it to 0. I could then increase it up to useful levels again. Really odd...
 
@garjon: If all you want to do is spam a specific item, I'd recommend not using BatBrain, actually. It'll run faster using a regular CCS.

However, it's also possible using BatBrain. This would be your entire script:

PHP:
import <BatBrain.ash>

void main(int initround, monster foe, string pg) {
   act(pg);          // load the page and build the list of all your combat options
   macro(get_action($item[someitemorother]),"");      // the "" means repeat with no conditions)
}

@Winterbay: No clue!
 
It appears I communicated my intent poorly.
Here's one place I'm running into issue.

PHP:
# The Snitch needs 6 jerksickles, then to spam attack while he kills himself.
if ( contains_text(page, "The Large-Bellied Snitch") ) {
	if( item_amount( $item[dangerous jerkcicle] ) < 6 ) {
		runaway();
		}
		enqueue(get_action($item[dangerous jerkcicle]));
		enqueue(get_action($item[dangerous jerkcicle]));
		enqueue(get_action($item[dangerous jerkcicle]));
		enqueue(get_action($item[dangerous jerkcicle]));
		enqueue(get_action($item[dangerous jerkcicle]));
		enqueue(get_action($item[dangerous jerkcicle]));
		macro(get_action("attack"), "");
	}
I've also tried
PHP:
		enqueue(get_action($item[dangerous jerkcicle]));
		enqueue(get_action($item[dangerous jerkcicle]));
		enqueue(get_action("attack"));
		macro(get_macro(""));
	}

All it does when it encounters the Snitch is spam attack.

How do I get it to throw the 6 cicles, and then spam attack, in one macro?
I'm doing this in ash, so that when the Thorax comes up, it can be responsive to text, and when the Pinch comes up, it can select an attack item based on my inventory. I'm starting to feel like I should have gone with just a standard CCS.
 
This is really off-topic, but here is my Dis CCS:
Code:
[ clumsiness grove ]
section dis_combat

[ default ]
attack with weapon

[ dis_combat ]
attack with weapon

[ glacier of jerks ]
section dis_combat

[ maelstrom of lovers ]
section dis_combat

[ mammon the elephant ]
item dangerous jerkcicle

[ the bat in the spats ]
item clumsiness bark

[ the large-bellied snitch ]
item dangerous jerkcicle
item dangerous jerkcicle
item dangerous jerkcicle
item dangerous jerkcicle
item dangerous jerkcicle
item dangerous jerkcicle
item dangerous jerkcicle
item dangerous jerkcicle
item dangerous jerkcicle
item dangerous jerkcicle
attack with weapon

[ the terrible pinch ]
sub spam
    "attack"
    "use jar full of wind"
endsub
call spam; repeat

[ the thorax ]
attack with weapon
item clumsiness bark

[ thug 1 and thug 2 ]
item jar full of wind

It works well (except when simply attacking isn't enough to kill the pinch!).
 
Wouldn't call it off topic; just letting me know I'm trying to hammer a nail with a sledgehammer. Hope you don't mind if I use it, and go about my merry way. I didn't know you could use a sub in a ccs.
 
This is another case for an "ongoing" advevent to exist in BatBrain, methinks. If jerkcicles were set to deal 250 ongoing damage (or whatever the number, depending on the frequency of belly-flopping, and assuming they had happened < 10 times this combat), attack_action() would probably choose them over your regular attack anyway, thus making special case code unnecessary.

I'll try to get that worked into the next BatBrain release. There are a number of other things that would also improve as a result (trolls, poison, etc).
 
Well, I wasted several hours tracking down a bug today.

Despite updating BatBrain to use the same checks as mafia for detecting combat completion (namely,

PHP:
((get_property("serverAddsCustomCombat") == "true" && !contains_text(action,"(show old combat form)")) || !contains_text(action,"fight.php"))

), I was still encountering issues when working on my relay script. It seemed to be correctly detecting combat completion only some of the time, completely arbitrarily. Finally, I tracked it down -- I am doing a 100% Bugged Bugbear run for my first exploratory play through Bugbear Invasion, and some of that familiar's action messages actually contain "fight.php", meaning that BatBrain (and probably mafia as well) thought the combat was still going on, even though it had ended.

I went on a wild goose chase with this; first I thought it was only happening when I spammed an action to kill the monster since that seemed to be a way to reproduce it -- but that was just a correlation since the increased number of rounds per page load increased the probability that one of those familiar actions would be on the page.

Should I make a bug report? Can anyone suggest a better check in this case? Shall I go back to checking for the beginning of the combat form, like I used to do? Hmmm.

EDIT: After a lot of experimentation, I'm now checking for either action=fight.php or action="fight.php" instead of just fight.php, and that seems to work for all cases so far.
 
Last edited:
Did you skip the check for "<!--WINWINWIN-->" mentioned in this post? The only way there should be a problem is if you don't win the fight and the bugbear gets to perform an action anyway (and the CAB isn't enabled, of course).
 
I skipped WINWINWIN as suggested in that very post, for the reason given and since it doesn't apply to losses or draws. I think I'll finally cave in and add it though, since the vast majority of combats are probably won (especially using BatBrain! hehehe), and it reduces the edge cases.

There were two such edge cases: 1) our buggy friend's false positive (which fooled both mafia and BatBrain), and 2) victory against a monster which gives another link to fight.php, such as Ed or the NS (which fooled only BatBrain). Adding WINWINWIN eliminates the second one and vastly reduces the first -- only draws and losses where the message fires (quite possible when spamming an action -- I lost several times against the new bugbears because I'd set my unknown_ml to a number too optimistic and then tried to plink them to death) would still be evaluated incorrectly.

Changing the check to "action=fight.php" rather than "fight.php" correctly ignores the bugbear's "Parse error in fight.php" message, and probably also the links for Ed/NS (but haven't checked that yet), so it might be good for both BatBrain and mafia to change that and actually be entirely rather than mostly accurate.

EDIT: Yay, Jason's recent change to floats has just eliminated all the situations where scientific notation was throwing off the formula evaluations! No more of those pesky "Expression syntax error for 'modifier_eval()': expected end, found E-8" messages. w00t
 
Last edited:
First thanks to everyone who keeps Mafia alive and evolving. I know this has been discussed elsewhere and I have tried the various solutions but I keep getting these Evaluator syntax errors. I have updated my zlib, wham, smart statis, universal recovery to the latest version. I am using the current latest hourly mafia build. I even went into the data file and deleted the contents forcing everything to check for updates. Did I hose something? Did I miss something? Can some please give me a pointer to remove these syntax errors. Thanks!


1047] Giant's Castle
Encounter: Raver Giant
Round 0: Tom Sawyer Jr wins initiative!
> Updating batfactors.txt to '2012-05-29T11:05:28-05:00'...
> ...batfactors.txt updated.
> Checking for updates (running BatBrain ver. 1.23)...
> Running BatBrain version: 1.23 (current)
> Checking for updates (running SmartStasis ver. 3.15)...
> Running SmartStasis version: 3.15 (current)
> Checking for updates (running WHAM ver. 2.5)...
> Running WHAM version: 2.5 (current)
> Updating pluralMonsters.txt to '2012-01-22T22:44:50-06:00'...
> ...pluralMonsters.txt updated.
Evaluator syntax error: can't understand {333.0}
> WHAM: Running SmartStasis
Round 1: Tom Sawyer Jr executes a macro!
Round 1: Tom Sawyer Jr tries to steal an item!
You acquire an item: giant needle
Round 2: Typical reaches down and pulls some Meat from behind your ear. Didn't your mother ever tell you to wash back there?
Round 2: You gain 14 Meat.
Round 2: Typical climbs up and sits on your shoulder, and hands you some Meat. Huh, where did he find that?
You gain 79 Meat.
Evaluator syntax error: can't understand {333.0}
Evaluator syntax error: can't understand {333.0}
Evaluator syntax error: can't understand {333.0}
> WHAM: Monster is weak. We are just going to bash its head in. It'll take 4 rounds.
Round 2: Tom Sawyer Jr executes a macro!
Round 2: Tom Sawyer Jr attacks!
Round 3: raver giant takes 48 damage.
Round 3: Typical reaches down and pulls some Meat from behind your ear. Didn't your mother ever tell you to wash back there?
Round 3: You gain 8 Meat.
Round 3: Tom Sawyer Jr attacks!
You lose 3 hit points
Round 4: Typical reaches down and pulls some Meat from behind your ear. Didn't your mother ever tell you to wash back there?
Round 4: You gain 11 Meat.
Round 4: Tom Sawyer Jr attacks!
Round 5: raver giant takes 50 damage.
Round 5: raver giant takes 1 damage.
Round 5: raver giant takes 5 damage.
You lose 3 hit points
Round 5: Tom Sawyer Jr attacks!
Round 6: raver giant takes 49 damage.
Round 6: Typical holds out the Mayflower bouquet toward your opponent. He stops to smell the flowers instead of attacking you.
Round 6: Tom Sawyer Jr attacks!
Round 7: raver giant takes 51 damage.
Round 7: Tom Sawyer Jr wins the fight!
After Battle: Typical holds the Mayflower bouquet out in front of you, and you stop to smell the flowers. It reminds you that the best things in life are free. Then you remember that you can keep them for the birds and bees, and start sniffing around for extra Meat.
After Battle: Typical surveys the scene from atop the throne, and gains 1 Experience.
After Battle: Typical sits on your fallen opponent's body, blows a smoke ring, and winks at you.
You gain 1085 Meat
You acquire an item: Mick's IcyVapoHotness Rub
You gain 9 Strengthliness
You gain 8 Magicalness
You gain 30 Cheek
 
Evaluator syntax error: can't understand {333.0}

Ditto but have just not had the time and energy to make a proper report, just my intuition that it is in SmartStasis or something SS refers to.
 
The number in the brackets are your maximium HP. SmartStasis doesn't directly call the evaluator, only BatBrain does. After a little sniffing, I think I found the cause. batfactors for the soggy used band-aid doesn't properly match any regex in BatBRain. The nearest one is on line 474:
Code:
      matcher rng = create_matcher("\\{.+?,(.+?),.+?}",sane);
but since the band-aid's entry uses -{maxhp} it doesn't match and subsequently doesn't get handled. Placing my band-aids in my closet stops the error from popping up. I tried removing the {} from it's batfactors entry and that worked.
 
Yeah, batfactors has apparently received an error in an upload at some point. I've uploaded a corrected version now so it should fix itself over the next few days.
 
I just went through a couple days ago and added a bunch of the more recent items that were missing. Thanks for catching and fixing my mistake, teammates.
 
So, I think I've found a bug: When BatBrain tries to enqueue Stealth Mistletoe before DB actions it exises "skill " and then runs a to_skill on the resulting number. But if SmartStasis (or in this case WHAM) decides to send it a combo (so "skill 5003; skill 5005; skill 5008") it will fail since it tries to run a to_int() on "5003; skill 5005; skill 5008".

Not so much of a problem, but a bit unnecessary.
 
Using WHAM in softcore I came across an unfortunate lack in BatBrain.

BatBrain does not know about "Makes you a Crack Shot" attribute of the Operation Patriot Shield. This increases the hit chance of ranged combat by +100. It would be nice if BatBrain knew I could hit those pesky high level monsters instead of using Harpoon! Ah well, with a megadrone seated on my crown of thrones I didn't miss the MP too much,
 
The OPS doesn't seem very well implemented as it stands. I only acquired one very recently, but WHAM used 'throw shield' before suckerpunch a whole lot... Often it would use "entangling noodles, throw shield, suckerpunch" to stasis with a megadrone in my CoT. Obviously "throw shield, entangling noodles, suckerpunch" would be infinitely preferable.

If this behaviour has been altered recently I apologise, I saw this happening a while ago and Bales post reminded me to mention it :)
 
Back
Top