Intrinsics mod #16

wants to merge 7 commits into


None yet

2 participants



I found the searches done in 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.


CJBrew added some commits Sep 18, 2011
@CJBrew CJBrew 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.
@CJBrew CJBrew Added a test for the intrinsics search/parsing. d5d6c95
@CJBrew CJBrew added new tests 46e4d0b
@CJBrew CJBrew Refactoring d584a8f
@CJBrew CJBrew Moved Intrinsic module to within the codebase, removed logging that w…
…as causing a perfomance issue.
@CJBrew CJBrew Collate all the lines of message data together before searching for m…
…essages, in case the message goes across multiple lines.
@CJBrew CJBrew intrinsics.cpp : Using Boost::regex to search in C++ for intrinsics. : Since we're now looking at regex search we don't want full stops in the search strings - removed. Also removed are exclamation marks. : 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.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment