Rule and Event Systems

From RogueBasin
Revision as of 12:30, 20 October 2011 by Rsaarelm (talk | contribs) (Created page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Rule systems and event systems describe how a world model evolves in time. They intend to make it easier to describe complex interactions between entities in the world model, compared to writing the behavior out in engine code.

A rule system has rules in the form of "IF condition THEN effect", which are constantly being checked when the game is running, with the effect triggering if the condition is met. The key difference here is that the rule writer does not explicitly attach the rules to the control flow of the game engine code, the engine iterates through the rules automatically and triggers the ones where the condition is fulfilled. The problems include rules coming into conflict, increased difficulty in understanding control flow and possible performance problems caused by large rule sets. There is research on this technique using the term "forward chaining inference".

An event system is more about the effect parts of the rules. It reifies events that cause changes in the game world into objects, which can then be put into a delay queue, logged for debugging, logged as transactions that can be rolled back, intercepted and modified and downright ignored. Event objects are also handy for a publish/subscribe game AI architecture, where the in-game AI is passed certain types of events and reacts to them. Using events involves a more complicated control flow and overall program architecture, but they might be useful for making complex interactions that happen over spans of in-game time easier to describe.

References