Winding Road Ahead: Designing Utility AI with Curvature
Created on 2023-10-01T01:00:55-05:00
Outcome package: determines the behavior script an NPC will adopt, parameters to that, what conditions are necessary, and what conditions make the package a desirable selection
Utility Theory: for any situation calculate how appealing each outcome package is and choose the best one
Components
Sensors: gather information about the world being acted upon; positional hazards, health, status effects...
Filters: process sensor data by multiplying it through curves ("response curves")
Scoring: combine filtered sensor data together to determine how desirable this outcome package is
Attributes
Constant attribute: something which is set upon an actor by the designer.
Derived attribute: something which is calculated based on world state.
Validation: setting a valid range for attributes.
Validation metadata is used to guide the editor. It says a creature may have health between 1 and 99,999, or mana may be between 1 and 100, and so on.
Knowledge Base
Prefab Equations: ID number for a function in the engine. Done this way in the video to make the author's work easier. Actual engines tend to put a script chunk or an editor here.
The knowledge base is information about the world and actors in question. You bind [derived] properties of candidates to names and possibly run them through a predefined equation to do something with it. Names bound from the knowledge base are then used in conditions.
Behavior
Behaviors are what bind a job script, parameters, scoring criteria, and a name together.
If the behavior is chosen then the NPC sets its current job to the one defined by this behavior. Those jobs are defined elsewhere (in code) and the Utility AI simply selects the priority to apply each job.
Considerations
Input: a variable from the knowledge base which is scored by a single point of consideration
Filtering: remaps the input to a customizable space (ex. within a given range only.)
Curve: applies some mathematical curve to the input which has been remapped by the filter.
Filtering turns the input variable to a range of 0-1, then this 0-1 is fed through the response curve to transform to an actual desirability score.
Natural language tools
- A preset browser that asks basic questions about the desired curve (such as "not interesting and then becomes interesting quickly") proposes inverse power curves.
- A wizard that goes through a step of common questions to configure a consideration based on just following the instruction list.
Bundles of Targets
Behaviors might apply an action to a number of targets. For example whether to heal an ally has a behavior defined as when a single target should be healed--scaling based on amount of health missing, rapidity of health loss, distance from the caster. The behavior is then cloned across valid targets
Standalone tools
- Splitting AI code and editors out of the engine lets you iterate independent of the rest of the pipeline
- Most game engines do not support real time editing
- Quick feedback is vital to maintain flow / learn faster