Recent from talks
Nothing was collected or created yet.
Utility system
View on WikipediaIn video game AI, a utility system, or utility AI, is a simple but effective way to model behaviors for non-player characters. Using numbers, formulas, and scores to rate the relative benefit of possible actions, one can assign utilities to each action. A behavior can then be selected based on which one scores the highest "utility" or by using those scores to seed the probability distribution for a weighted random selection. The result is that the character is selecting the "best" behavior for the given situation at the moment based on how those behaviors are defined mathematically.
Key concepts
[edit]The concept of utility has been around for centuries – primarily in mathematically dependent areas such as economics. However, it has also been used in psychology, sociology, and even biology. Because of this background and the inherent nature of needing to convert things to math for computer programming, it was something that came naturally as a way of designing and expressing behaviors for game characters.
Naturally, different AI architectures have their various pros and cons. One of the benefits of utility AI is that it is less "hand-authored" than many other types of game AI architectures.[1] While behaviors in a utility system are often created individually (and by hand), the interactions and priorities between them are not inherently specified. For example, behavior trees (BTs) require the designer to specify priorities in sequence to check if something should be done. Only if that behavior (or tree branch) is NOT executed will the behavior tree system fall through to check the next one.
By comparison, behaviors in many utility systems sort themselves out by priority based on the scores generated by any mathematical modeling that defines every given behavior. Because of this, the developer isn't required to determine exactly where the new behavior "fits" in the overall scheme of what could be thousands of behavior "nodes" in a BT. Instead, the focus is on simply defining the specific reasons why the single behavior in question would be beneficial (i.e. its "utility"). The decision system then scores each behavior according to what is happening in the world at that moment and selects the best one. While some care must be taken to ensure that standards are being followed so that all behavior scoring is using the same or similar premises, the "heavy lifting" of determining how to process tens – or even hundreds – of different behaviors is offloaded from the designer and put into the execution of the system itself.
Background
[edit]Early use
[edit]Numbers and formulas and scores have been used for decades in games to define behavior. Even something as simple as a defining a set percentage chance for something to happen (e.g. 12% chance to perform Action X) was an early step into utility AI. Only in the early 21st century, however, has that method started to take on more of a formalized approach now referred to commonly as "utility AI".
Mathematical modeling of behavior
[edit]In The Sims (2000) an NPCs current "need" for something (e.g. rest, food, social activity) was combined with a score from an object or activity that could satisfy that same need. The combinations of these values gave a score to the action that told the Sim what it should do. This was one of the first visible uses of utility AI in a game. While the player didn't see the calculations themselves, they were made aware of the relative needs of the Sim and the varying degrees of satisfaction that objects in the game would provide. It was, in fact, the core gameplay mechanism.
In The Sims 3 (2009), Richard Evans used a modified version of the Boltzmann distribution to choose an action for a Sim, using a temperature that is low when the Sim is happy, and high when the Sim is doing badly to make it more likely that an action with a low utility is chosen.[2] He also incorporated "personalities" into the Sims. This created a sort of 3-axis model — extending the numeric "needs" and "satisfaction values" to include preferences so that different NPCs might react differently from others in the same circumstances based on their internal wants and drives.
In his book, Behavioral Mathematics for Game AI,[3] Dave Mark detailed how to mentally think of behavior in terms of math including such things as response curves (converting changing input variables to output variables). He and Kevin Dill went on to give many of the early lectures on utility theory at the AI Summit of the annual Game Developers Conference (GDC) in San Francisco including "Improving AI Decision Modeling Through Utility Theory" in 2010.[4] and "Embracing the Dark Art of Mathematical Modeling in AI" in 2012.[5] These lectures served to inject utility AI as a commonly-referred-to architecture alongside finite state machines (FSMs), behavior trees, and planners.
A "Utility System"
[edit]While the work of Richard Evans, and subsequent AI programmers on the Sims franchise such as David "Rez" Graham[6] were heavily based on utility AI, Dave Mark and his co-worker from ArenaNet, Mike Lewis, went on to lecture at the AI Summit during the 2015 GDC about a full stand-alone architecture he had developed, the Infinite Axis Utility System (IAUS).[7] The IAUS was designed to be a data-driven, self-contained architecture that, once hooked up to the inputs and outputs of the game system, did not require much programming support. In a way, this made it similar to behavior trees and planners where the reasoner (what makes the decisions) was fully established and it was left to the development team to add behaviors into the mix as they saw fit.
Utility with other architectures
[edit]Additionally, rather than a stand-alone architecture, other people have discussed and presented methods of incorporating utility calculations into existing architectures. Bill Merrill wrote a segment in the book, Game AI Pro,[8] entitled "Building Utility Decisions into Your Existing Behavior Tree"[9] with examples of how to re-purpose selectors in BTs to use utility-based math. This made for a powerful hybrid that kept much of the popular formal structure of behavior trees but allowed for some of the non-brittle advantages that utility offered. Utility AI can also be integrated with other architectures in a modular approach, where each architecture handles a specific task. For example, in a study,[10] the authors applied a Utility System to calculate the utility values of high-level strategic orders in a team-based tactical game, while Monte Carlo Tree Search (MCTS) was employed to execute these orders at the tactical level.
See also
[edit]References
[edit]- ^ Mark, Dave (August 2012). "AI Architectures: A Culinary Guide".
- ^ Evans, Richard. "Modeling Individual Personalities in The Sims 3". GDC Vault. pp. 36–38. Retrieved 21 September 2015.
- ^ Mark, Dave (March 2009). Behavioral Mathematics for Game AI. Course Technology Cengage Learning. ISBN 978-1584506843.
- ^ Mark, Dave; Dill, Kevin (2010). "Improving AI Decision Modeling Through Utility Theory". GDC Vault.
- ^ Mark, Dave; Dill, Kevin (2012). "Embracing the Dark Art of Mathematical Modeling in AI". GDC Vault.
- ^ Graham, David "Rez" (September 2013). "An Introduction to Utility Theory" (PDF). GameAIPro.
- ^ Mark, Dave; Lewis, Mike (2015). "Building a Better Centaur: AI at Massive Scale". GDC Vault.
- ^ Rabin, Steve (September 2013). "Game AI Pro". Amazon.
- ^ Merrill, Bill (September 2013). "Building Utility Decisions into Your Existing Behavior Tree" (PDF). GameAIPro.
- ^ Świechowski, M.; Lewiński, D.; Tyl, R. (2021). Combining Utility AI and MCTS Towards Creating Intelligent Agents in Video Games, with the Use Case of Tactical Troops: Anthracite Shift. 2021 IEEE Symposium Series on Computational Intelligence (SSCI). Orlando, FL, USA. pp. 1–8. doi:10.1109/SSCI50451.2021.9660170.
Utility system
View on GrokipediaCore Concepts
Definition and Purpose
A utility system is an AI architecture in which agents assess multiple possible actions or behaviors by computing and comparing numerical utility scores, ultimately selecting the action with the highest score to optimize expected outcomes in dynamic environments.[1] This approach models decision-making by quantifying the desirability of each option relative to the current context, enabling agents to adapt flexibly without predefined hierarchies or scripts.[1] The primary purpose of a utility system is to support complex, context-sensitive decisions in real-time settings, especially for non-player characters (NPCs) in simulations and games, by emulating rational choice under uncertainty.[1] Unlike rigid rule-based systems, it allows agents to balance competing factors—such as resource availability or environmental threats—to produce emergent, believable behaviors that enhance immersion and interactivity.[1] Utility systems draw briefly from foundational economic and psychological decision models, where utility represents preference under risk, though their adaptation to AI prioritizes practical computation over theoretical rigor. For instance, in a video game scenario, an NPC might evaluate the "attack" action against "flee" by scoring each based on variables like its own health level, distance to the enemy, and the opponent's perceived strength, choosing the option that yields the superior overall utility to simulate tactical reasoning.[1]Key Components
Utility systems in artificial intelligence, particularly within game development, are composed of modular elements that enable agents to evaluate and select actions based on contextual data. These components facilitate dynamic decision-making by breaking down complex choices into quantifiable scores, allowing for adaptive behaviors without rigid scripting.[1] Considerations serve as individual evaluators that assess specific aspects of the environment or agent state, such as health levels, resource availability, or proximity to threats. Each consideration processes input data—often normalized game variables like health percentage or distance metrics—and maps it to a utility score typically ranging from 0 to 1, representing desirability or urgency. This mapping commonly employs response curves to introduce nuance; for instance, linear curves provide straightforward proportional scaling, while sigmoid curves offer smooth transitions that accelerate or decelerate based on thresholds, mimicking realistic priorities like escalating danger. In practice, a "hunger" consideration might use a piecewise linear response curve where the utility score remains low until satiety drops below 50%, then rises sharply to prioritize foraging or eating, as seen in simulations of virtual agents.[1][4] Such dynamic scoring supports the overall purpose of utility systems by enabling agents to respond fluidly to changing conditions.[1] Selectors function as aggregation mechanisms that combine scores from multiple considerations to compute an overall utility value for each potential action. Common methods include weighted sums, where considerations are multiplied by importance factors before summation, or min/max operators that emphasize the most critical factor, ensuring balanced yet prioritized evaluations. For example, in tactical scenarios, a selector might weigh health and distance considerations to determine if evasion is preferable over engagement. This aggregation step is crucial for comparing disparate actions on a unified scale.[1] Actions or behaviors represent the discrete options available to the agent, such as attacking, healing, or retreating, each associated with a tailored set of considerations. These actions are evaluated holistically through the system, with their linked considerations providing context-specific scores; for instance, a "charge attack" action might draw from distance and ally proximity considerations to assess viability in melee combat. By linking actions to modular evaluators, utility systems allow for extensible behavior modeling without overhauling core logic.[4] Modifiers act as dynamic adjusters that refine consideration scores or weights in response to external variables, enhancing adaptability to situational nuances. These can include runtime factors like recent action history to prevent repetition or contextual influences such as environmental conditions, applied via adjustable curves or multipliers. In multi-agent environments, modifiers might amplify scores based on alliance status, favoring cooperative actions with allies over neutral parties. This layer ensures scores reflect broader game states, promoting coherent and varied agent performance.[1]Historical Development
Origins in Decision Theory
The foundations of utility systems trace back to early decision theory in economics and psychology, where scholars sought to model rational choice under uncertainty. In 1738, Daniel Bernoulli introduced the concept of expected utility in his paper "Specimen Theoriae Novae de Mensura Sortis," addressing the St. Petersburg paradox by distinguishing between expected monetary value and subjective utility. Bernoulli argued that individuals exhibit risk aversion because the utility of wealth diminishes at the margin, such that the expected utility of a gamble may be less than the utility of its expected value, providing an early framework for quantifying preferences over risky outcomes rather than mere financial gains. This line of thinking culminated in the axiomatic approach of John von Neumann and Oskar Morgenstern in their 1944 book Theory of Games and Economic Behavior. Their utility theorem established that rational preferences over lotteries—probabilistic combinations of outcomes—can be represented by a cardinal utility function, allowing decision-makers to maximize expected utility under risk. The theorem's proof relies on four key axioms: completeness, which requires that preferences are defined for all pairs of options; transitivity, ensuring consistent rankings without cycles; continuity, which permits mixtures of outcomes to approximate indifference; and independence, stipulating that preferences between options remain unchanged when mixed with a third option in the same proportions. These axioms provide a rigorous foundation for representing subjective preferences numerically, enabling the formal analysis of decisions in uncertain environments.[5][6] In this framework, utility serves as a measure of preference satisfaction or desirability, rather than an absolute indicator of happiness or pleasure. Von Neumann and Morgenstern emphasized that utility functions are unique up to positive affine transformations, capturing relative rankings of outcomes without implying interpersonal comparability or direct ties to emotional states. This conceptualization influenced the modeling of rational agents in uncertain settings, laying the groundwork for later applications in fields requiring decision-making under risk.[6]Early Applications in Computing and AI
In the 1950s and 1960s, utility-based decision-making began influencing early artificial intelligence systems, particularly in planning and problem-solving. The General Problem Solver (GPS), developed by Allen Newell, J. C. Shaw, and Herbert A. Simon in 1959, utilized utility-like evaluations to guide search processes by assessing the worthiness of goals and the likelihood of success through heuristics, such as means-ends analysis, which prioritized operators reducing differences between current and goal states.[7] This approach marked an initial computational adaptation of evaluative measures to navigate complex planning tasks, simulating human-like heuristic search in domains like logic puzzles. Parallel developments in operations research integrated utility objectives into simulations for economic modeling and resource allocation. During this period, linear programming techniques, as formalized in Tjalling C. Koopmans' activity analysis framework (1951), optimized linear objective functions representing utility maximization—such as value or efficiency—subject to resource constraints, enabling efficient allocation in production and transportation problems.[8] These methods provided a foundational tool for computational simulations, emphasizing quantitative trade-offs in decision scenarios with multiple constraints. By the 1970s, expert systems introduced preliminary utility scoring to support decisions under uncertainty, particularly in medical diagnosis. MYCIN, an early backward-chaining system developed at Stanford University, employed certainty factors—a form of probabilistic scoring—to quantify confidence in hypotheses about bacterial infections and recommend therapies, aggregating evidence from rules to handle incomplete clinical data. This represented an evolution in decision support, where scores enabled nuanced evaluations beyond binary rule firing. A pivotal advancement came with the introduction of multi-attribute utility theory (MAUT) by Ralph L. Keeney and Howard Raiffa in 1976, which formalized structured methods for aggregating preferences across multiple criteria in complex, real-world decisions, influencing subsequent AI applications in evaluation and selection.[9] These early implementations highlighted a broader shift from purely rule-based systems, which struggled with incomplete information, to score-based selection mechanisms that incorporated probabilistic or evaluative weights to manage uncertainty more effectively.[10] By assigning numerical utilities or certainty values to options, systems like MYCIN and those inspired by MAUT improved robustness in dynamic environments, laying groundwork for hybrid approaches in AI decision-making.Emergence in Game Development
The adaptation of utility systems to video game AI began in the late 1990s, with early implicit applications in strategy games where scoring mechanisms guided unit behaviors without fully formalized utility frameworks. These approaches were often embedded within finite state machines, prioritizing efficiency over explicit utility calculations. Formal utility AI emerged around 2000 through academic and industry explorations, particularly in needs-based decision-making for simulating believable agents. The Sims (2000) pioneered this by using utility scoring to balance competing needs such as hunger and social interaction, where actions were selected based on normalized scores reflecting need urgency and environmental opportunities.[11] This needs-based model, akin to utility theory, allowed modular action evaluation, influencing subsequent game designs focused on emergent behaviors. Throughout the 2000s, utility systems gained traction via industry discussions contrasting them with finite state machines for creating more adaptive AI. Game Developers Conference (GDC) sessions in the decade, such as those evaluating utility-driven decisions against scripted FSMs, highlighted their potential for believable NPC responses in dynamic environments.[12] A key milestone was Dave Mark's 2009 book Behavioral Mathematics for Game AI, which popularized utility curves for mapping situational inputs to action desirability, enabling nuanced NPC choices like tactical retreats or resource prioritization.[13] Adoption expanded in mid-2000s titles, propelled by the demands of open-world games for scalable, non-scripted behaviors, allowing AI to handle vast player interactions without exhaustive manual tuning.[1]Mathematical Foundations
Utility Functions
In utility systems, the utility function serves as the foundational mathematical construct, defined as a mapping from a given state of the environment and an action available to the agent to a real-valued score that quantifies the desirability of selecting that action in that state.[14] This score reflects the agent's preferences, enabling systematic evaluation of options under uncertainty or multi-objective scenarios common in artificial intelligence applications.[3] Utility functions can take various forms depending on the complexity of the preferences being modeled. Linear utilities, which assume constant marginal desirability, are suitable for simple preference structures where each factor contributes proportionally to the overall score.[15] In contrast, non-linear utilities incorporate realistic behavioral nuances, such as diminishing returns, where additional gains in one attribute yield progressively less benefit, allowing for more sophisticated modeling of agent decision-making.[16] A common formulation for utility functions in practice is the weighted sum approach: where represent weights indicating the relative importance of each feature, and are individual feature functions that evaluate specific aspects of the state-action pair, such as resource availability or goal proximity.[15] This additive structure facilitates computational efficiency while capturing multi-attribute trade-offs. To ensure comparability across different actions or states, utility scores are typically normalized to the interval [0, 1], with 0 representing the least desirable outcome and 1 the most desirable, thereby standardizing evaluations regardless of the underlying scale of individual features.[1] For agents exhibiting risk aversion, utility functions can be derived as concave, reflecting the principle that the desirability of gains diminishes as they increase, consistent with prospect theory's value function for gains.[17] This concavity implies a preference for certain outcomes over risky ones with equivalent expected value, as formalized in the theory by Kahneman and Tversky (1979).[17] In scenarios involving probabilistic outcomes, the expected utility is computed as , where denotes the probability of each possible result, providing a basis for rational choice under uncertainty in line with von Neumann-Morgenstern utility theory.[16] These functions ultimately inform action selection by ranking options according to their computed utilities.Action Selection Algorithms
Action selection algorithms in utility systems determine the most appropriate action for an agent by evaluating and comparing utility scores derived from consideration evaluations. These algorithms typically operate after individual utility scores for each action have been computed, selecting the action that maximizes overall utility to enable contextually adaptive behavior in dynamic environments such as video games.[18][1] The foundational approach to action selection is threshold-based maximization, where the algorithm chooses the action with the highest aggregated utility score , defined as , with as the set of possible actions, as the considerations relevant to action , as weights, and as normalized scores from 0 to 1. This method ensures decisive behavior by prioritizing the action deemed most desirable under current conditions, often implemented in real-time systems for efficiency.[18][1] A common aggregation technique within this framework is the weighted sum, which combines multiple consideration scores into a single utility value for each action: , where weights reflect the relative importance of each consideration and sum to 1 for normalization. This linear combination allows designers to tune agent priorities, such as emphasizing survival needs over exploration in resource-scarce scenarios, and scales well for agents with 5–20 actions.[1] For illustration, a basic pseudocode implementation of action selection using maximization might proceed as follows:function selectAction(actions, considerations):
bestAction = null
bestUtility = -[infinity](/page/Infinity)
for each action in actions:
utility = 0
for each [consideration](/page/Consideration) in considerations[action]:
score = evaluateConsideration(consideration, currentState)
utility += weight[consideration] * score
if utility > bestUtility:
bestUtility = utility
bestAction = action
return bestAction
function selectAction(actions, considerations):
bestAction = null
bestUtility = -[infinity](/page/Infinity)
for each action in actions:
utility = 0
for each [consideration](/page/Consideration) in considerations[action]:
score = evaluateConsideration(consideration, currentState)
utility += weight[consideration] * score
if utility > bestUtility:
bestUtility = utility
bestAction = action
return bestAction
