UML CLASS DIAGRAM FOR MODULAR PRIORITISED AI SYSTEM (UNITY3D) – TIMELINE: 1.5 WEEKS
what is it
it’s an easy-to-use artificial intelligence system for games where a programmer can write simple, seperate scripts with conditions and actions that can then be dragged and dropped by designers in the inspector in unity3d.
the user can tweak values to their liking, such as changing the amount of health below which the Associated Action should be executed, or which action should be prioritised if more than one Condition returns true.
for example, it might be better for gameplay purposes if an enemy prioritises healing themselves when on low health over pushing a button that feeds fish, which can be done by making the Action Priority value of an Action higher:
how it works
the system works using a base script called EnemyAI, which loops through all Conditions in an Array of MonoBehaviours, and executes the one that returns true AND has the highest Action Priority value:
any Condition and Action the programmer writes has to derive from ConditionBase and ActionBase respectively, and then override their public virtual bool Condition() and public virtual void Action() methods, which means that whenever EnemyAI executes an associatedAction.Action() method, it executes the custom one deriving from the base class.
the code to the base classes and how they would be implemented, in the order ConditionBase > ActionBase > ExampleCondition > ExampleAction, is shown below: