Skip to content

Core Concepts

◄hollsteinm► edited this page Jan 20, 2024 · 10 revisions

The core structures of RPAI are several classes defined in the framework. These classes are URpaiState, URpaiGoalBase, URpaiActionBase, URpaiReasoner, and URpaiPlanner. Respectively these are known as a State, Goal, Action, Planner, and Reasoner The classes are well documented in source code and in the code documentation; however, we will cover descriptions of each. Below is an overview describing how each concept interacts.

---
title: Reasonable Planning AI Relationships
---
erDiagram
    Goal ||--|| State : "value to pursue"
    Goal ||--|| State : "distance from point"
    Action ||--|| State : "estimates work"
    Action ||--|| State : "projects future"
    Reasoner ||--o{ Goal : "scores value"
    Reasoner ||--|| State : "uses"
    Reasoner ||--|| Goal : "outputs"
    Planner ||--o{ Action : "sequences work"
    Planner ||--|| State : "starts from"
    Planner ||--|| Goal : "targets"
    Planner ||--o{ Action : "outputs"
Loading

State

State is the glue between the game world and the Reasonable Planning AI reasoners and planners. It is a data centric object focused on copying information from the game world to support reasoning and planning. It is similar in functionality and purpose as a Blackboard. A State object defines an interface for interacting with various named data types. This allows the usage and creation of different types of states. This allows designers and developers to create different AI with different information. It also enables the usage of different Reasoners and Planners with different states so long as the data elements align. It also allows the usage of different Goals and Actions with different States to make the system more flexible.

Goal

A Goal is used to determine the utility of some abstract overarching thing to accomplish. A good goal is broad in concept, but identifiable in definition. An example of a good goal is “Satiate” or “Fight”. A good goal can be accomplished by many means. Using the previous example, “Satiate” could be accomplished by actions of gathering either food or water and either eating - which involves more actions - or drinking.

Goals have two primary heuristics used to determine the value of pursuing a goal. The first is the weight. This is a dynamic value that changes based on a given State. The second is the Category. This is typically a static value used to prioritize over lesser goals despite the weight of those lesser goals indicating more value in pursuing. An example of a Goal that ought to have a higher priority category over others is “Death”, indicating a termination Goal of the agent.

A goal also exposes functionality to determine a distance heuristic to indicate how far a given state is from the desired state of a goal.

Action

An Action is used to determine the utility of some specific action. An Action exposes methods to determine how expensive it is to perform based on a given state, and a guard to determine if the action is applicable to a given state. Finally, it provides a method of modifying a given state to determine the future state if this action is performed.

An action should represent a granular task a pawn can perform. It should be as granular as playing an animation or performing a game specific task - such as eating following our current examples. An action also has functionality exposed to command a pawn to perform specific functionality during gameplay.

The action has functions for determining planning heuristics as well as game execution code. This makes an action the bridge from the logical components of RPAI - which execute outside of the context of the game world - and the game world your pawns exist within.

Reasoner

A Reasoner accepts a set of goals that are possible and the current state. Given the set of goals, the reasoner will use a combination of the calculated weight and category to determine the value of each goal. The value of a goal is used to determine, based on the current state, the most important goal to pursue. Once determined, a single goal is output to indicate the most valuable goal to pursue.

Planner

A Planner accepts a single goal and a set of possible distinct actions that can occur for a given agent, and the current state of the pawn. With this information the planner will output a list of actions to execute in sequence to accomplish - or nearly accomplish - the given goal. A planner is what ultimately produces outcomes that will impact the game world by giving a pawn a set of actions to complete.

Below is an example of a given goal with a given plan for two separate pawns. It showcases how plans are not always the same based on the given state.

journey
    title Sample Actions from Target Goal
    section Earn Money Goal
      Grab Axe Action: 1: "Woodless Lumberjack"
      Walk to Nearest Tree Action: 2: "Woodless Lumberjack"
      Chop Tree Action: 3: "Woodless Lumberjack"
      Split Log Action: 4: "Woodless Lumberjack"
      Pick up Wood Action: 5: "Woodless Lumberjack", "Stockpiled Lumberjack"
      Walk to Market Action: 6: "Woodless Lumberjack", "Stockpiled Lumberjack"
      Sell Wood Action: 7: "Woodless Lumberjack", "Stockpiled Lumberjack"
Loading

Conclusion

Armed with this knowledge you have the basic foundational understanding of Reasonable Planning AI (RPAI). Continue onto the next section to learn about the workings of the RPAI Runtime.

Clone this wiki locally