RTree Overview
RTree is a collaborative planning system.
Collaborative planning is using natural language to co-plan and coordinate actions with in-game NPC. This approach permits players (and NPCs) to assign NPCs high-level tasks, which are then broken down into discrete substeps, each with its own context and criteria.
How does collaborative planning relate to existing game AI approaches?
Collaborative planning systems are designed to work in conjunction with faster, low-level game AI systems such as behavior trees or hierarchical task networks (HTNs). A plan may have steps which are actions, such as going to a location or playing a certain line of dialogue, or steps which initiate AI traditional AI functions, such as a BP_PatrolArea()
behavior tree.
If Cyberpunk 2077 was built with RTree, you could tell a companion, “I'm going to sneak into the rival gang’s hideout. I need you to recruit 3 mercenaries and at exactly 11 pm, attack the main entrance as a distraction so I can free the prisoners." RTree could decompose this statement into the relevant in-game actions (pseudocode below, however in RTree, each action a model can take is implemented as a UE5 Gameplay Ability):
GoTo(Location::EnemyHideout, 23:00) # (1)!
Spawn(Allies::Mercenaries, 3) # (2)!
EngageNearbyEnemies() # (3)!
└ BehaviorTree_AttackNearby() # (4)!
This would be implemented as a UE5 Gameplay Ability.
This is yet another UE5 Gameplay Ability.
UE5 Gameplay Abilities are the main interface for RTree!
Conventional game AI systems such as behavior trees are invoked from within a calling UE5 Gameplay Ability. RTree uses the UE5 Gameplay Ability System as a context manager which validates the output of the model with the current state of the game. Once an ability is validated, it can be activated and any effects in its overidden
ActivateAbility()
method are called.
Workflow of an RTree Action
RTree handles the nitty-gritty parts of entire request->plan generation->action execution loop. This includes all parts of local, asynchronous inference, parameter validation, and action execution and action status tracking. The following diagram presents a medium-resolution overview of these steps. Of these, only the two purple steps are required to be implemented by game developers. Check out the tutorial to see in-detail how to set up the parts that require implementation by the developer.
graph TD
A["Player enters request"] --> B["Grab latest perception results from cache."]
B --> C["ProcessObservations() on the project-specific subclassed version of RTreeAIController is called. Developers overide this method with logic that updates any saved state relevant to perceived actors. For example, this could be newly discovered locations that we need to save."]
C --> D["Next, Render JSON-7 validation schema for each Gameplay Ability . Developers can write abilities to update validation on-the-fly based on saved perceptions, such as discovered locations that the model can choose to go to."]
D --> E["Combine perception information, actions (Gameplay Ability tool call JSONs), and player request into prompt."]
E --> F["Build async job and add to RTree job queue."]
F --> G["Worker thread builds batch from dequeued jobs."]
G --> H["Load batch onto GPU and compute result"]
H --> I["For each action JSON in the plan produced by the model:"]
I --> J{"Validate response"}
J -->|"Passes validation"| K["Call requisite UE5 gameplay abilities with parameters"]
J -->|"Fails validation"| L["Resubmit job with validation error"]
L --> E
K --> M["Activate ability"]
M --> N{"Plan step succeeds?"}
N -->|"Yes"| O["Continue to next step action in model-produced plan."]
O --> N
N -->|"No"| P["Process new perception and replan."]
P --> B
classDef start fill:#05a4ce40,stroke:#05a4ce,stroke-width:2px,color:#000
classDef devresponsibility fill:#9933cc40,stroke:#9933cc,stroke-width:2px,color:#000
classDef decision fill:#ff8c0040,stroke:#ff8c00,stroke-width:2px,color:#000
classDef success fill:#2e8b5740,stroke:#2e8b57,stroke-width:2px,color:#000
classDef error fill:#dc143c40,stroke:#dc143c,stroke-width:2px,color:#000
class A start
class C,D devresponsibility
class J,N decision
class M success
class P error
subgraph Process["RTree Planning System"]
B
C
D
E
F
G
H
I
J
K
L
end