Devlog 1 - Goal-Oriented Action Planning System (GOAP )


Goal-Oriented Action Planning System - GOAP

GOAP system, the full name is called goal-oriented action planning system. It is a construction concept of an AI behavior system. By knowing the goal first, then reversely deriving it in the behavior library, the system will finally output a behavior chain as the AI ​​action guide.

The whole system consists of three important parts, they are Goal Generator, Action Planner and Action Sequencer.

Goal Generator

As the name suggests, the task of the goal generator is to decide for the AI what it wants to do. The functionality of this part should be highly customizable, so I will describe how I created an object generator based on a city dweller simulation in the following pages.

Action Planner

The action planner is designed to find an appropriate action chain for the goal. Here I use a nested function to find all relevant downstream actions for an input of a target until it finds an action that does not require any input.

The Action Planner Execution Process:

  1. Get input goal
  2. According to the goal, get all the actions that meet the goal requirements as the root action
  3. Traverse all root actions, use nested functions to find all action chains based on root actions, and store them in variables.
  4. Compute the execution cost for each stored variable
  5. Return the lowest-cost behavior chain
  6. Parsing behavior chain to an executable behavior data array.

Action Sequencer

The Action Sequencer will execute the actions until they are all completed according to the determined action sequence.

There is a problem here. In the blueprint of the unreal AI Controller, the node used to execute a behavior tree is Run Behavior Tree. It has an input parameter that requires an instance of a behavior tree. However, when switching behavior tree data, if the behavior tree to be switched is the same type as the previously executed behavior tree. Unreal will consider this to be a repeated input and automatically ignore the new toggle behavior tree.

Run Behavior Tree Node

The solution is to switch the behavior tree to an empty entity before executing the switch behavior tree. It must have a behavior tree entity, although there can be no behavior in the behavior tree.

Run an empty node before the real behavior tree Node

I made a special behavior tree task at the end of each behavior tree, let it notify the AI controller that the current behavior has been completed. And the AI controller performs the action of switching tasks after hearing the message.

A end behaviour task always in the end

Switch to next action in AI Controller

Get GOAP Project (UE5)

Leave a comment

Log in with itch.io to leave a comment.