Alyssa Knez

Gameplay Programmer

GOAP System

GOAP AGENT (C#)



private void Update()
{
    if (!isActive) return;

    // Get a new plan if we don't have an action
    if (currentAction == null)
    {
        CalculatePlan();

        if (actionPlan != null && actionPlan.Actions.Count > 0)
        {
            navMesh.ResetPath();

            currentGoal = actionPlan.AgentGoal;
            currentAction = actionPlan.Actions.Pop();

            if (currentAction.Preconditions.All(b => b.Evaluate()))
            {
                currentAction.Start();
            }
            else
            {
                currentAction = null;
                currentGoal = null;
            }
        }
    }

    // Execute current action
    if (actionPlan != null && currentAction != null)
    {
        currentAction.Update(Time.deltaTime);

        if (currentAction.Complete)
        {
            currentAction.Stop();
            currentAction = null;

            if (actionPlan.Actions.Count == 0)
            {
                currentGoal = null;
            }
        }
    }
} 

Goal:
Create a flexible AI system that allows enemies to dynamically choose goals based on priority, react to changing world conditions and execute a multi-step action plan.

Implementation:
I implemented a Goal-Oriented Action Planning system to drive enemy behavior. I also built a planning loop that evaluates available goals and generates action sequences at runtime and used priority-based goal selection to ensure more important behaviors override lower ones.

Result:
The AI adapts to the world around it, can create new goals, actions, and beliefs while also being intelligent in choosing goals.