I found the searches done in Brain.py to look for intrinsic gained/lost messages were slowing down the game considerably in some circumstances (especially when entering long-ish lines in the console; e.g. specifying wishes, naming items or engraving messages).
The search code was basically looping through Dictionaries of Dictionaries in Python, then applying a regex search to the results. To speed things up I've reimplemented the searching code in C++ with some pre-caching of the search terms and results, which seems to significantly improve performance.
This could be extended to the other dispatch functions (e.g. _dispatch_status_events() -- if the Brain gets cleverer more functionality might need to be compiled into modules.
Regular Expressions searching is handled using Boost::Regex -- I hope that dependency isn't a problem. Boost is easily installable through aptitude or similar.
Try some c++ code to optimise searches through the text. Start with i…
…ntrinsics and if it works, roll into other dispatch methods.
This is intermediate checkin and breaks the functionality temporarily.
Added a test for the intrinsics search/parsing.
added new tests
Moved Intrinsic module to within the codebase, removed logging that w…
…as causing a perfomance issue.
Collate all the lines of message data together before searching for m…
…essages, in case the message goes across multiple lines.
intrinsics.cpp : Using Boost::regex to search in C++ for intrinsics.
intrinsics.py : Since we're now looking at regex search we don't want full stops in the search strings - removed. Also removed are exclamation marks.
setup.py : modified the Extensions build info to link against libboost_regex
For the moment I'm going to let this sit in limbo. I have a big change coming through (previewed on the proper-mapping) branch that I'd like to finish for 0.3, then make this (and other perf improvements) part of the upcoming (heretofore non-existant) 0.4 branch.
Hopefully I'll be able to finish proper-mapping this week and then merge 0.3 back to master at which point this commit will be the start of the new dev branch.