When is better than If
Message handling leads to polling. Would like co-routines instead of messages. Nestable coroutines would allow reusable behaviors
Messages must be able to change the program counter.
Why Game AI is difficult: no direct language support for multitasking, no changing execution state without polling, and complexity issue.
Polling is the heart of the problem.
Light switch with polling – easy for simple case, gets exponentially more complicated very quickly. Even with messages, it turns to polling.
PROC system – light switch with fade. Started as coroutine system in 68000 assembler. Later implemented in C and C++. Most recently implemented in C# in Unity. Implements HFSM with message handling, nested coroutines. Message handling terminates children who can’t handle the message.
At the heart of the difficulty of robust and rich behavior in games is the limitation of popular programming languages. Either make additions to languages, or systems to fake them.
The core problem is how to manage the response to input data that changes over time.
Design your architecture to hide the polling problem as much as possible.
What about Functional Reactive Programming? What about Monads?
Fast? Or Good?
Good enough is good enough.
Battlefield – average lifespan of NPC is 5 seconds.
But there are outlier cases. Companions, for one.
GOAP! F.E.A.R’s AI system, Jeff Orkin, based on STRIPS. Creates novel solutions to problems. Adopted by other games – Just Cause 2, Deus Ex. Falling out of favor. GOAP only allows for abstract planning about broad strategies.
Search in the best case is NP-Hard.
GOAP was always the lowest hanging fruit of planning. Academic planning has moved on, focuses on large-scale dedicated planning, but uses slow large algorithms.
I2A – Integrated Influence Architecture. Perform a chunk of work during development time. Allow agent to be informed by reasoning while reacting to the world.
Influence mapping allows for simple contingencies. Fuzzy clustering to find focal nodes, structurally significant. These are the nodes that fall outside any cluster.
Avoiding search as much as possible, smart abstraction and horizon management, reaction and deliberation simultaneously inform decisions.
Can merge location and conceptual reasoning together. Navigation problem, but navigating through concepts.
Infinite Axis Utility System
Behavioral Mathematics for Game AI talks about utility systems.
For each action, there are multiple considerations (axis), each has input and parameters. List of Axis, so easy to add more, even an infinite number.
Actions with targets are scored per target. Push final scores onto potential action list. Pass things through response curves. Curve types: linear, exponential, logistic, logit. Type, m, k, b, c. Take tuple, clamp input, calculate, clamp output. Multiply actions to get one output value, normalized 0..1. Define bookends, anything outside is clamped.
Input clearing house to normalize inputs. Run through all actions generically.