Ok, the
r59 Update brings BatBrain up to speed with the modifier changes.
It also brings us some more batfactors parsing optimizations. In addition to tweaking the order of things as per Veracity's post, I have eliminated two functions:
normalize_dmgtype() and
parse_factors(), and have moved all of their functionality into various places around the script, for an improvement in both speed and functionality.
Previously BatBrain was foreaching each factor in batfactors and search/replacing the keywords "prismatic", "sauce", "pasta", and "perfect" with a calculated-each-time list of elements. Since very few of the entries actually contain any of these keywords, that was mostly a big waste of time. Not only that, but actually editing factors is undesirable in the event that you change monsters mid-fight or use BatBrain predictively outside of combat against a series of monsters, since the damage elements for some of those keywords may change with the monsters. So:
- The code for replacing "prismatic" in batfactors is now performed in the static section and will thus only be performed once per session. This is just an expansion of shorthand and is not dependent on the monster.
- The code for calculating "pasta" now happens in set_monster() and is saved to a global variable. Thus it should be recalculated -- but only once, instead of every time -- whenever you change monsters. It is applied on the fly when building the specific Pastamancer skills (there are now only 4) containing that keyword, without actually altering factors. Thus, if you change monsters, the new "pasta" element(s) will be recalculated.
- Likewise, the code for determining "sauce" is now only performed when building the one skill remaining in the game that uses that keyword (Saucegeyser).
- The code for determining "perfect" has also been moved into set_monster(), and is applied in to_spread() without altering the source.
- The code for removing underwater-only items when not underwater has also been moved to set_monster(), though I don't think it will stay there, since, again, you may change locations when predicting, and then having options missing from factors would be undesirable. But for all presently known uses of BatBrain, this will continue to serve for now.
All told, the total performance increase between BatBrain of three revisions ago vs. now is massive. A difference of roughly
an entire second in runtime (thanks mainly to Veracity's awesome "static" scope). I feel extremely happy about that, and I'm also excited for the actions-loading revamp that's on the way next. Actions whose results are not dependent on any variables will be loaded statically and will thus not need to be calculated each time, saving us even more time! BatBrain will conquer its nemesis once and for all!
As always, enjoy!