SOAP: Goal Oriented Action Planning in Unreal Engine 4 (4.15)

Hello! Me and a friend are doing our bachelor’s thesis this semester, and what we settled on doing is implementing Goal Oriented Action Planning - GOAP - into Unreal Engine 4.

What is GOAP?
If you want to really dig into what GOAP is, the best thing to do is to look to the original creator of it: Jeff Orkin. You can read more on GOAP here. For this thread, I’m going to stick with the basics.

The basics of GOAP is roughly as follows:

  • An AI agent has a goal that it wants to accomplish. To achieve the goal, it has a number of actions available.
  • Each action is characterized by conditions. It has postconditions, i.e what it will accomplish in doing the action, and preconditions, i.e what needs to happen before this action can be done.
  • The planner starts by selecting all actions whose postconditions satisfy the goal. I.e if the agent is hungry, but can eat a pizza, donut or cookie, all of those are valid actions.
  • However, an action has preconditions, or requirements before that action can be performed. For example, to eat any of the above items you need to purchase them.
  • The planner will find all actions that satisfy the preconditions.
  • When finally our action can be performed without any other actions we have a starting point.
  • The above steps have effectively created a graph, which we can use A* to traverse and find the cheapest path to our goal.

A rundown of our project:
Initially we named our group SOAP in homage to two things: Jeff Orkin’s “GOAP, rhymes with soap”, as well as the kind of game we initially wanted to make with it - tactical singleplayer shooter. However, the latter homage is somewhat on the sidewalk now, as we decided that time spent into developing the AI systems was time saved later down the road. Therefore, we restructured our project at the time to focus more on GOAP itself, i.e creating a functional prototype in Unreal Engine 4, as well as creating a tool to utilize it with relative ease.

Our project is separated into two main phases, as well as a bonus phase. These phases are:

  1. Creating a functional GOAP algorithm in Unreal Engine 4
  2. Establish a means of easily utilizing the above algorithm
  3. Create a basic videogame prototype that utilizes the toolkit

We have a functional algorithm as of now. At this point, we’ve moved from our initial prototype stage, and we’re now looking to make this a tool for easier AI development in UE4. We’re making this thread now because we’re hoping for some basic feedback on how your experience in UE4 is today in developing AI, and how we can move to improve it.

Frankly, I’m a little new to this – as in I’m not entirely sure what I should really write about in this thread, so if you have any questions I’ll be happy to answer as well as expand on this post more meaningfully. Our advisor suggested, during our project planning, to “share what you have - and if they have questions, answer those questions in the plan” - I hope to employ a similar tactic here. I just wanted to share what we’re working on, for now.

Thank you all for your time. :slight_smile:

GOAP is good.
I wrote one for my project that had the AI find a gun and find ammo before engaging the player.
It worked out pretty well.
can’t wait to see what you come up with.

Really intrigued with this idea. I enjoyed the HELL out of F.E.A.R.'s gunplay and was even MORE intrigued by the articles praising the AI system in it. Are you guys planning on sharing your finished product in the end? Getting nitty gritty into systems like this is crack for programmers like me. :stuck_out_tongue:

Good to see more people working on GOAP, good luck with it :slight_smile:

My GOAP plugin is pretty much finished now, code is on github, might want to take a look for inspiration, I’ve seen a lot of different implementations and papers elaborating on the fundamentals.

Your graph traversal is different from mine. I start at the current agent state and BFS available actions from there. I then just walk back from all the valid goal-satisfying nodes to find the cheapest. For A* to be useful you need a heuristic and I haven’t figured out a good way to implement one yet.