Fantasy RPG concept art showing a sword, coins, an ancient map, and a dragon-emblazoned book, symbolizing goals, actions, and planning in game AI (GOAP).

By

-

October 10, 2025

Share With Friends

GOAP in Game AI: Using Utility and Planning for Smarter NPCs

Table of Contents

After publishing my recent piece on game AI planning, I received a wave of questions about GOAP, which inspired me to write this article. To make it clear and approachable, I’ll walk through a simple paper prototype of GOAP so you can both understand the concept and even implement your own version if you’d like.

Goal-Oriented Action Planning (GOAP) was developed by Jeff Orkin in 2004 and shipped a year later in F.E.A.R. by Monolith Productions. That makes this year special, GOAP is officially 21 years old (old enough to drink) and it’s been 20 years since its debut shook up how game AI was designed.

Back then, GOAP made headlines because enemies in F.E.A.R. didn’t just follow scripted patterns, they planned. They could flank, retreat, regroup, or push the player dynamically, all because GOAP treated AI as problem-solvers rather than puppets.

Around 2015, Monolith shifted away from GOAP for its later AI systems such as the Nemesis system which was built on top of behavior trees. However, GOAP never really disappeared. Many developers, from indies to AAA teams, still use it, because it remains one of the cleanest ways to make AI that feels smart, flexible, and reactive.

So in this article, we’ll celebrate GOAP’s “drinking age” by walking through how to use it in practice. We’ll set up a small survival world, introduce our NPC, and show step by step how GOAP can solve their daily challenges. Along the way, we’ll highlight strengths, limitations, and practical workarounds, and even touch on how Utility systems can complement GOAP to make smarter decisions.

Meet the NPC

This is Ari, and she has a long day ahead of her. She wakes up in the House on a chilly morning, knowing that by nightfall the temperature will drop even further. To stay warm, Ari will need to gather enough wood for a fire. But before she can think about the evening, there are urgent needs pressing in: she’s hungry (6/10), thirsty (4/10), and has a small amount of water left in her container (1/4). Ari also knows the land around her well. But traveling between them isn’t without risk, if she crosses the Wolf Den, she must be careful and take precautions to stay safe (slower movement +2 Distance).

The Situation

Ari checks the pack: an axe hangs off the side, but the backpack’s weight limit is 10. The water container can hold 4 units (1/4 full).
Berries are quick calories, fish is more filling (especially cooked), and wood is bulky but required for warmth and cooking. Travel burns a little stamina: each unit of distance adds +0.25 hunger and +0.25 thirst, and chopping wood adds +1 thirst and +1 thirst. Crossing the Wolf Den is risky, Ari must Hide to pass safely (extra cost) if the route goes through it.

Today’s objective:

  1. Eat (satisfy X hunger)

  2. Drink (satisfy X thirst)

  3. Stay Warm by night (build a fire at House)

To better understand Ari’s world, let’s take a look at her surroundings. The map shows the key locations she can travel to during the day.

A survival world map showing five locations connected by paths with movement costs. The House connects to the Berry Bush (cost 3) and the Tree Grove (cost 4). The Berry Bush connects to the River Bank (cost 2). The River Bank connects to the Wolf Den (cost 1). The Wolf Den connects to the Tree Grove (cost 2). Each number along the path represents the travel cost in distance.

Ari’s backpack holds up to 10 weight, with each item taking a different amount of space. The water container is separate and can store up to 4 units.

Items Slots
Axe 2
Wood (log) 3
Fish 2
Berries 1
Water 1

Each action Ari can take has a location, an effect on her state or inventory, and a cost. Some also add penalties, like movement increasing hunger and thirst, or chopping wood making her thirsty.

Action Effect Cost Location
Move To: Change Location Distance to Location
Hunger +0.25 x distance
Thirst +0.25 x distance
Gather Berries Berries +3 Berry Bush
Fish Raw Fish +2 River Bank
Chop Wood Log +1 Thirst +2 Tree Grove
Hunger +1
Cook Fish Cooked Fish +1 Raw Fish -1 Home
Wood -1
Eat Berry Hunger -1 Berry -1
Eat Raw Fish Hunger -2
Eat Cooked Fish Hunger -4
Fetch Water Water +4 (max) River Bank
Drink Water Water -1
Thirst -3
Build Fire Fire Wood -2 Home
Hide Safe Passage Distance +3
Drop Item Storage -X Item
Retrieve Item Storage +X

Problem One: Ari Needs to Eat

Ari’s most urgent goal is to eat. Starting with no food in her inventory, the planner uses A* to evaluate possible paths: moving to the Berry Bush (cost 3, heuristic 1) or the Tree Grove (cost 4, heuristic 4, leading to fish at the River). The Berry Bush becomes the better option, so Ari gathers berries and eats, reducing hunger by 1 but also raising hunger and thirst slightly (+0.75 each) due to the travel cost.

After gathering berries and eating one, Ari is left with 5.75 hunger and 4.75 thirst. Since she already has berries in her inventory, the planner runs again.

  • Next Action: Eat Berry

    • Cost: 1 action

    • Effect: Hunger −1

  • Resulting State: Hunger = 4.75, Thirst = 4.75

The planner sees another berry still available in the inventory, so it takes the action again:

  • Next Action: Eat Berry

    • Cost: 1 action

    • Effect: Hunger −1

  • Resulting State: Hunger = 3.75, Thirst = 4.75

Problem Two: Stuck in a Loop

At this stage, Ari has solved her immediate hunger by eating berries, but the planner will keep selecting the same action until hunger reaches 0. The issue is that Ari still has other needs during the day, like collecting wood for warmth and managing thirst, but GOAP, when executed in a simple top-to-bottom manner, will stay locked on the first listed goal.

This creates a loop: gather berries → eat → repeat, even though thirst is growing and should now be the higher priority. What we really need is a system that can adaptively re-prioritize goals based on urgency.

This is where a decision taker like Utility system comes in. By assigning a score to each goal based on Ari’s current state, the planner can dynamically recognize which need is more important, like noticing she’s more thirsty than hungry, and shift focus accordingly:

  • Eat: Utility = function of Hunger (the hungrier Ari is, the higher the score)

  • Drink: Utility = function of Thirst (the thirstier Ari is, the higher the score)

  • Stay Warm: Utility = function of Time of Day + Wood in storage

  • Other needs: can be added with their own scoring formulas

For example:

  • Utility(Eat) = Hunger / 10

  • Utility(Drink) = Thirst / 10

  • Utility(Warmth) = (IsNight ? 1 : 0.3) × (1 − WoodInStorageFactor)

At the start of the day, Ari is hungry (6/10) and thirsty (4/10), so the scores might look like this:

  • Eat = 0.6

  • Drink = 0.4

  • Stay Warm = 0.2

So the planner first solves eating. But as soon as Ari’s hunger drops to 3.75 and thirst rises to 4.75, the scores shift:

  • Eat = 0.375

  • Drink = 0.475

Now “Drink” jumps above “Eat.” The Utility system tells GOAP to switch priorities and run a new plan focused on fetching water instead of staying locked on eating.

With Utility in place, the planner now ranks drinking above eating, since Ari’s thirst is the more urgent need. Instead of continuing to eat berries, Ari uses the Drink Water action from her container.

  • Action: Drink Water

    • Cost: 1

    • Effect: Thirst −3

  • Resulting State: Hunger = 3.75, Thirst = 1.75

By shifting goals dynamically, the Utility system prevents Ari from staying stuck in a “just keep eating” loop and makes her behavior feel more natural.

Returning to Eating

Once Ari drinks, her thirst drops to 1.75, making hunger the higher priority again. Since she’s already at the Berry Bush, the planner selects the most efficient option: gather more berries and eat.

  • Action 1: Gather Berries

    • Cost: 1

    • Effect: +3 berries (weight +3)

  • Action 2: Eat Berry

    • Cost: 1

    • Effect: Hunger −1

Resulting State: Hunger = 2.75, Thirst = 1.75

By combining GOAP for planning and Utility for prioritization, Ari adapts her decisions naturally: she quenches thirst first, then returns to eating when hunger becomes the bigger issue.

Problem Three: Preparing for Warmth

With both hunger and thirst now under 0.3, Ari’s next highest priority shifts to staying warm. To achieve this, she needs to gather wood and return to the House to build a fire.

The planner now sets its goal to Warmth, which means plotting a path to the Tree Grove using A*. For clarity, we’ll display the A* pathfinding table to show the cost and heuristic calculations for the AI movement.

A pathfinding table showing possible routes to the Tree Grove with costs, heuristics, and totals. The paths listed are: (1) Berry Bush → Home, cost 0, heuristic 7, total 7; (2) Berry Bush → River Bank, cost 0, heuristic 5, total 5; (3) River Bank → Wolf Den, cost 2, heuristic 3, total 5; (4) Wolf Den → Tree Grove, cost 6, heuristic 2, total 8; (5) Home → Tree Grove, cost 3, heuristic 4, total 7; (6) Tree Grove, cost 7, heuristic 0, total 7.

Once Ari arrives at the Tree Grove, she can begin chopping wood. Each chop provides logs but also comes with a trade-off:

  • Thirst +1 (physical effort)

  • Hunger +1 (energy spent)

Problem Four: Handling Interrupts

With some wood collected, Ari is closer to her warmth goal, but moving and chopping has raised her hunger back to 5.5 and thirst to 4.5. She hasn’t finished the fire task yet, but continuing would only push her deeper into dangerous need levels.

This is where an interrupt becomes essential. Instead of blindly following through on the “Stay Warm” goal, the planner pauses the current task, stores the gathered wood, and switches to the more urgent needs. Ari eats her 2 berries to lower hunger, but since her water container is empty, she now has to plan a trip to the river to drink and refill.

Problem Five: Expanding Goals with Resource Collection

Up to now, Ari’s planner has been focused on short-term survival: eat when hungry, drink when thirsty, and gather wood when warmth is needed. All the actions already exist — Fish, Gather Berries, Cook Fish, Store Items — but they only made sense in service of those immediate goals.

To move beyond reactive behavior, we need to expand the goal set and add:

New Goal: Collect Resource Reserves

  • Stockpile extra food for later.

  • Keep the water container filled.

  • Store surplus wood at the House.

Nothing changes in the action table, the actions are already there. What changes is how the Utility system scores them. By adding “Collect Reserves” into the utility calculation, the planner can now recognize that:

  • Hunger is low → Eat has low utility.

  • Thirst is covered → Drink has very low utility.

  • Warmth isn’t yet urgent → Stay Warm is moderate.

  • Fish is right here at the River → Collect Reserves is the highest utility.

So instead of idling or repeating unnecessary tasks, Ari begins fishing for later use. The same actions are applied, but now they serve a long-term proactive goal instead of only reacting to immediate needs.

Problem Six: Returning Home for Warmth

Ari has managed to eat, drink, and even collect reserves for the night ahead. But one last challenge remains: returning home and lighting the fire before sunset. To do this, she must bring wood back to the House, manage her hunger and thirst during the trip, and decide whether to cook fish or keep them for later. She’ll need to balance the cost of travel, the weight in her backpack, and her remaining energy.

This is a perfect point to hand control over to you, the reader. Using the tools we’ve explored (GOAP for planning, A* for pathfinding, Utility for prioritizing goals, and Interrupts for adapting to urgent needs) run the planner and decide how Ari should finish her day.

This is where you, the reader, come in.

Your challenge: run the planner with Ari’s current state and goals, and determine the most likely sequence of steps she would take to end her day safely.

  • Which path will A* choose to get her home?

  • How many wood logs does she need to carry back?

  • Does the Utility system push her to eat or drink along the way?

  • What is the final order of actions that builds the fire and secures her survival for the night?

By running the planner yourself, you’ll see how GOAP finds the sequence while Utility ensures Ari adapts to shifting priorities.

Ready to Bring Smarter AI Into Your Game?

If you’d like to go beyond examples and implement Utility systems, GOAP planners, efficient pathfinding, or other Game AI solutions directly into your project, check out our Technical Offer. We can help you and your developers design, implement, and optimize AI systems that make your NPCs feel smarter, more adaptive, and more engaging.

FAQ: Goal Oriented Action Planning (G.O.A.P.)

What problem does GOAP solve?
GOAP (Goal-Oriented Action Planning) solves the how of decision-making. Instead of hardcoding action sequences, it looks at the NPC’s state, goals, and available actions, then builds a plan dynamically. This makes NPCs adapt naturally to changing situations.

Why add Utility on top of GOAP?
GOAP knows how to reach a goal, but it doesn’t know which goal should come first. Utility gives each goal a score based on urgency (e.g., thirst vs. hunger) so the planner can always pick the most important one.

How does A* fit into this system?
GOAP decides what to do, but A* decides how to get there efficiently. For example, when Ari needs fish, GOAP picks the goal and actions, while A* finds the shortest path to the River while accounting for travel costs and risks.

What are interrupts and why do they matter?
Interrupts let the planner stop a long-term goal when urgent needs spike. For example, if Ari is chopping wood but her hunger rises too high, an interrupt allows her to pause, eat, and then return to woodcutting. Without interrupts, NPCs risk “failing” by stubbornly following through on the wrong plan.

Do I need to keep adding new actions to expand the system?
The advantage of a GOAP system is flexibility. You can easily add or remove actions, and you can also define whether a goal is valid or invalid based on the current world state. If a goal isn’t valid, the planner simply skips it and goes to the next goal in the list until it finds one that can succeed. This makes it easy to adjust or expand the system without rewriting everything from scratch.

Can this scale beyond survival examples?
Yes. The same principles apply to combat, stealth, squad coordination, and even social AI. Any time an NPC needs to balance multiple goals under constraints, GOAP with Utility is a strong fit.

stay tuned

Subscribe to our newsletter to hear the latest news

videogame development

We specialize in empowering game developers to turn their creative visions into reality. With a deep understanding of the gaming industry, our expert team offers tailored project management and production solutions that streamline workflows, enhance collaboration, and optimize resources. We’re dedicated to helping developers of all sizes navigate the complexities of game development, ensuring they stay on track and achieve their goals. Together, we bring innovative ideas to life, one game at a time.