I have a problem with the SRPG rulebook that I’ve been intentionally ignoring while there are still only a few rules. Namely, specificity. The situation is similar to that of CSS specificity.
Right now, Rules are checked in the order they were added, which has the side effect of making overlapping rules effectively random in order. That said, the Rule system is marginally resistant to the randomness, as multiple rules can apply to an action and can stack outputs (or cancel execution entirely).
In the interest of making the process more predictable, I’m working on a plan for calculating specificity of Rules, and executing them in order from most specific (‘rule for walking north from dim clearing while the door is locked and the player has the key’) to least specific (‘rule for walking while the player has the key’).
There are some implementation details to work out with the weighting (assuming I don’t go with a naive approach based simply on the number of conditionals). The ‘callback’ conditionals are especially tricky, as they can conceal additional conditionals within their custom code. The ability to directly assign a boosted specificity score might be useful (similar to the bad-practice !important keyword in CSS), but I’d like to avoid it if possible.