BatBrain -- a central nervous system for consult scripts

Code:
> ash 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 replace_string(sane, "prismatic", "hot,cold,spooky,sleaze,stench"); } deranged("max(2,fweight/2-max(0,(fweight-(20+20*famgear)))*zone(sea))+5*famgear)")

Returned: max(2,fweight/2-max(0,(fweight-(20+20*famgear)))*zone(sea))+5*famgear)
Yep, passes the deranged check now.
 
Decided to massively over-engineer the sanity check. Here goes.
Code:
ashq 
import <zlib.ash> 
string badstring = "max";
string searchstring;
record combat_rec {
   string ufname;
   string dmg;
   string pdmg;
   string special;
};
 static {
   combat_rec [string, int] factors;
   record {
      int turns;
      string img;
   }[string] banishers;
}
load_current_map("batfactors",factors);
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 replace_string(sane, "prismatic", "hot,cold,spooky,sleaze,stench"); }
   foreach te,it,rd in factors {
      searchstring = rd.dmg;
      if (index_of(searchstring, "{") != -1 && substring(searchstring, searchstring.index_of("{"), searchstring.index_of("}")).contains_text(badstring)) print("Looks like "+te+" "+it+" has a bad dmg - "+deranged(searchstring));
      searchstring = rd.pdmg;
      if (index_of(searchstring, "{") != -1 && substring(searchstring, searchstring.index_of("{"), searchstring.index_of("}")).contains_text(badstring)) print("Looks like "+te+" "+it+" has a bad pdmg - "+deranged(searchstring));
      searchstring = rd.special;
      if (index_of(searchstring, "{") != -1 && substring(searchstring, searchstring.index_of("{"), searchstring.index_of("}")).contains_text(badstring)) print("Looks like "+te+" "+it+" has a bad special - "+deranged(searchstring));
}
Basically, add whatever bad string you want to search for in the 'badstring' line. I searched for both min and max, and fam 102 (imitation crab) was the only offender on those. If you come up with any other items that shouldn't be inside the range checks, you can easily-ish search your local batfactors for what's bad. Basically, we're just parsing between the {} brackets for our bad words. We look at the three strings that become deranged. It spits out a result like this:
Code:
> ashq import <zlib.ash> string badstring = "max"; string searchstring; record combat_rec { string ufname; string dmg; string pdmg; string special; }; static { combat_rec [string, int] factors; record { int turns; string img; }[string] banishers; } load_current_map("batfactors",factors); 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 replace_string(sane, "prismatic", "hot,cold,spooky,sleaze,stench"); } foreach te,it,rd in factors { searchstring = rd.dmg; if (index_of(searchstring, "{") != -1 && substring(searchstring, searchstring.index_of("{"), searchstring.index_of("}")).contains_text(badstring)) print("Looks like "+te+" "+it+" has a bad dmg - "+deranged(searchstring)); searchstring = rd.pdmg; if (index_of(searchstring, "{") != -1 && substring(searchstring, searchstring.index_of("{"), searchstring.index_of("}")).contains_text(badstring)) print("Looks like "+te+" "+it+" has a bad pdmg - "+deranged(searchstring)); searchstring = rd.special; if (index_of(searchstring, "{") != -1 && substring(searchstring, searchstring.index_of("{"), searchstring.index_of("}")).contains_text(badstring)) print("Looks like "+te+" "+it+" has a bad special - "+deranged(searchstring)); }

Looks like fam 102 has a bad dmg - max(2
 
The problem is actually the extra commas, not the min and max themselves.

Anyway, I'm a fan of not using ranges anymore to begin with, since the day when BatBrain cares about that is a very, very distant day. So, looks like you've fixed it.

You gain {debugdifficulty+3,max(debugdifficulty+5,10),min(debugdifficulty+7,20)} Moxiousness!
 
Yes. I merely listed those as the most common (only ones I could remember off the top of my head) functions that were used in the formulaes that might add bonus commas into the mess. As you say, it's not the min/max that's the problem, it's that it adds extra commas into the mess. The 'fix' would probably be to switch the split from comma to underscore or something else that isn't otherwise used, but... that involves effort. Averages do fine... until someone forgets and tries to get fancy... :)
 
It took me a little while to figure out why I was doing so much damage to the Protector Spirits. I was all... huh? Aren't they physically resistant? Then I observed about it with other ghosts as well.
 
Last edited:
BatBrain first needs to be aware of ghosts. Is there a way to know this without a hardcoded list?

We'll probably end up needing a keyword in batfactors for ghost monsters. Perhaps we can enlist the "onlyhurtby" keyword for this purpose.
 
BatBrain first needs to be aware of ghosts. Is there a way to know this without a hardcoded list?
I don't think Mafia's aware of that, either (not that it needs to be). The best way to determine whether a monster is a ghost or not is to go in with Pill Power (from power pill / mini power pill) active, as ghosts will be colored blue.
 
We could add a keyword to monsters.txt and pass it along as a proxy field. Not that we need it, as heeheehee said, but we've done of lot of things for the convenience of scripts.

This would be more likely were someone to post a list of ghosts...
 
Fortunately this has already been spaded. Here is the list of all ghosts:
http://kol.coldfront.net/thekolwiki/index.php/Category:Ghosts

Some monsters in KoL are ghosts. Ghosts are usually, though not always, physically immune, and usually of the undead phylum.

Some equipment and effects give the enchantment "+X damage against ghosts", which makes all physical attacks against ghosts deal X more damage (this bypasses any physical resistance that might be present).

The skill Hammer Ghost only works against ghosts.

Scroll of ancient forbidden unspeakable evil will insta-kill physically-immune ghosts when used (though Pill Power can stop it working).

The combat skill Pinch Ghost only works on ghosts.

The effect Pill Power makes all ghosts coloured blue, and strips them of all their physical resistance.

T.U.R.D.S. Keys have a significantly boosted free-runaway chance against ghosts.

The protonic accelerator pack has special interactions when fighting ghosts and allows use of the skills Shoot Ghost and Trap Ghost.

Ancient ghost
Ancient protector spirit (The Hidden Apartment Building)
Ancient protector spirit (The Hidden Bowling Alley)
Ancient protector spirit (The Hidden Hospital)
Ancient protector spirit (The Hidden Office Building)
Banshee librarian
Battlie Knight Ghost
Bettie Barulio
Boneless blobghost
Chalkdust wraith
Claybender Sorcerer Ghost
Cold ghost
Contemplative ghost
Dusken Raider Ghost
Emily Koops, a spooky lime
Ghost
Ghost actor
Ghost miner
Ghost of Elizabeth Spookyraven
Ghost of Fernswarthy's Grandfather
Hot ghost
Hustled spectre
Lovesick ghost
Marcus Macurgeon
Marvin J. Sunny
Mayor Ghost
Mayor Ghost (Hard Mode)
Model skeleton
Mortimer Strauss
Plaid ghost
Protector Spectre
Restless ghost
Sexy sorority ghost
Sheet ghost
Sleaze ghost
Space Tourist Explorer Ghost
Spirit of New Wave (Inner Sanctum)
Spirit of New Wave (Volcanic Cave)
Spooky ghost
Stench ghost
The ghost of Ebenoozer Screege
The ghost of Jim Unfortunato
The ghost of Lord Montague Spookyraven
The ghost of Monsieur Baguelle
The ghost of Oily McBindle
The ghost of Phil Bunion
The ghost of Richard Cockingham
The ghost of Sam McGee
The ghost of Vanillica "Trashblossom" Gorton
The ghost of Waldo the Carpathian
The Headless Horseman
The Icewoman
The Unknown Accordion Thief
The Unknown Disco Bandit
The Unknown Pastamancer
The Unknown Sauceror
The Unknown Seal Clubber
The Unknown Turtle Tamer
Whatsian Commando Ghost
Wonderful Winifred Wongle
 
Last edited:
Category pages are an often ignored source of information on the wiki. Some of them even have lists of everything that has a special interaction with that category.
 
If I read that right, then the proton thingy could be considered to be "+0 damage against ghosts" and not something new. I hadn't realized ghosts were not all physically immune.
 
We could maybe (internally) add a MonsterType enum, which would cover boss, ghost, and whatever else seems appropriate. Having boss included in two places for a while before eventually removing that field could be a thing. Just brainstorming here though.
 
If I read that right, then the proton thingy could be considered to be "+0 damage against ghosts" and not something new.

Oh. That's what I wasn't understanding quite right: +25 Damage vs. Ghosts.

That's what was going on! Apparently that +25 damage applies to regular attacks, not to special techniques. That's why I was doing damage with my regular attacks, but not other physical techniques. Weird.
 
Back
Top