Giter VIP home page Giter VIP logo

goap's People

Contributors

actions-user avatar crash-konijn avatar crashkonijn avatar j1018813 avatar jimmy-p avatar layla-p avatar mitsh avatar shashank42 avatar siliconorchid avatar warigeiko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

goap's Issues

Question: Possibility of override movement logic?

Hi! I'm sorry if I'm asking a stupid question. As I read in the FAQ: "The graph calculates distance between two actions, adding that cost automatically. Actions don't need to be aware of each other, or their relative position in the graph, making them simpler." Where would it be possible to redefine the logic of moving to the target and calculating the cost of this movement? As I understand it, now everything is based on lifetime logic, and I would like to adapt it to turn based grid logic.

P.s. I found IAgentMover on Life Cycles of Agent (https://goap.crashkonijn.com/general/lifecycle) but don`t see this interface inside project(

Feature: More flexible options as the ActionRunState

Is your feature request related to a problem? Please describe.
When using the run state in an action your options are now Continue and Stop. I'd like to create a class instead of an enum, this will allow for extra flexibility and to abstract certain logic away from the actions (for example waiting).

Describe the solution you'd like
There should be an interface instead of an enum, something like this:

public interface IActionRunState {
    bool ShouldStop();
    bool ShoulContinue();
    bool MayResolve();
}

Additional context
This will allow you to keep do things like:

  • ActionRunState.Stop: Stop the current action
  • ActionRunState.Continue: Continue the current action the next frame (don't allow new resolves)
  • ActionRunState.ContunueOrResolve: Continue the current action the next frame (do allow new resolves)
  • ActionRunState.Wait(float time): Continue the perform method once the timer is completed
  • ActionRunState.WaitForAnimation(...)

Stack Overflow

When an Acction depends on a Effect, that it effects itself,

preconditions.Add(Effects.BOMB_THROWN, false);
effects.Add(Effects.BOMB_THROWN, true);

it auses a stack overflow
(file paths shortened)

The requested operation caused a stack overflow.
    at (wrapper managed-to-native) System.Object.__icall_wrapper_ves_icall_array_new_specific(intptr,int)
    at System.Collections.Generic.Dictionary`2[TKey,TValue].Initialize (System.Int32 capacity) [0x0002f] in <599589bf4ce248909b8a14cbe4a2034e>:0 
    at System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x0001b] in <599589bf4ce248909b8a14cbe4a2034e>:0 
    at System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <599589bf4ce248909b8a14cbe4a2034e>:0 
    at KillMoleAction..ctor (SwordGC.AI.Goap.GoapAgent agent, System.Int32 targetPlayerId, BombType bombType) [0x00050] in ...\Actions\KillMoleAction.cs:28 
    at KillMoleAction.Clone () [0x00001] in ...\Actions\KillMoleAction.cs:77 
    at SwordGC.AI.Goap.GoapAgent.GetMatchingActionChilds (SwordGC.AI.Goap.GoapAction parent) [0x000b0] in ...\GOAP\Core\GoapAgent.cs:257 
    at SwordGC.AI.Goap.GoapAgent.GetMatchingActionChilds (SwordGC.AI.Goap.GoapAction parent) [0x000b9] in ...\GOAP\Core\GoapAgent.cs:257
    at SwordGC.AI.Goap.GoapAgent.GetMatchingActionChilds (SwordGC.AI.Goap.GoapAction parent) [0x000b9] in ...\GOAP\Core\GoapAgent.cs:257
    at SwordGC.AI.Goap.GoapAgent.GetMatchingActionChilds (SwordGC.AI.Goap.GoapAction parent) [0x000b9] in ...\GOAP\Core\GoapAgent.cs:257
    ...

This happenes probably because it tries to attatch the node to itself infinetely, and thus overflows.

In my oppinion, the possibility of something like that is very important. Most complex GOAP Graphs are not just linear, where one action sololy depends on others. It can very well be that a certain action depends on it actions that again depend on the action itself.

Maybe there must be a limit, on how many times a certain node can appear in a chain

Bug: The version on the Unity Asset Store is different than the Git and OpenUPM versions, and installs in a different folder

Describe the bug
When installing GOAP through the Unity Asset Store, the files are put inside the Assets folder, compared to when installing through Git or OpenUPM, which puts the files in Packages. They are also different, like the one in Packages are missing the demo files.

Is it normal?

Steps to Reproduce
Install the GOAP package with the Unity Asset Store or Git or OpenUPM.

Expected behavior
I would expect that installing using the Unity Asset Store would do the same as Git or OpenUPM, installing in the same location and having the same files.

Screenshots
If installed through Unity Asset Store:
Unity Asset Store

If installed through Git or OpenUPM:
Git : OpenUPM

Unity Version
2022.3.7f1

Unity.Collections Version
2.1.4

Package Version
2.1.11 (although the Git version is supposed to be 2.1.12, even if the package.json still says 2.1.11?)

Bug: The goal on the agent isn't cleared when a goal is completed

Describe the bug
When a goal is completed, the goal isn't cleared before the OnGoalCompleted event is being called. If the same goal is being set on the agent again it stops processing (it's the same goal) and this is confusing.

Clearing this could end up in a loop (with a frame delay), but is much more clear in what's happening.

Steps to Reproduce
Steps to reproduce the behavior:

  1. Wait for a goal to complete
  2. In the OnGoalCompleted handler set the same goal again

Expected behavior
It would be better if the goal is cleared.

Feature: Custom Distance Check

Would be nice if there was a way to adjust how the distance to a target is calculated. For example, when you use NavMeshAgent you want to use its remainingDistance.

Would also be neat if you can prematurely tell if a target is reached, say from the action itself. Example: Maybe you want the agent to stop when they see the target, instead of always stopping at a given distance.
Well, you can probably just return infinity as the stopping distance and that would basically act the sameπŸ€”

Feature: Settings window, including update notification

Is your feature request related to a problem? Please describe.
I'd like to introduce a general settings window. This could provide the following information:

  • The currently used version (useful for bug requests)
  • Checking for updates
  • Fix the pathing issue when the folders are moved -> moved to #147

Additional context
Best would probably be to introduce this before the next major release.

Proposal

if (activeActions[0].target != null && Vector3.Distance(transform.position, activeActions[0].target.transform.position) < activeActions[0].requiredRange)

First of all, great library, liked it more than ReGoap πŸ‘

But quick question... Why this line?
I'm pretty sure this should be precondition of the action?

Bug: "KeyNotFoundException: No action found of type WanderGoal" potential AgentBehaviour bug

Describe the bug
I'm currently trying to follow along the tutorial, and it seems like I'm getting stuck just at the very end. I was having trouble figuring out how to add/configure the Agent Behaviour component, so I added the one that was imported here: Assets/Imported/CrashKonijn/GOAP/Runtime/CrashKonijn.Goap/Behaviours/AgentBehaviour.cs

Now, when I hit play, I get the following error:

KeyNotFoundException: No action found of type WanderGoal
CrashKonijn.Goap.Classes.GoapSet.ResolveGoal[TGoal] () (at Assets/Imported/CrashKonijn/GOAP/Runtime/CrashKonijn.Goap/Classes/GoapSet.cs:53)
CrashKonijn.Goap.Behaviours.AgentBehaviour.SetGoal[TGoal] (System.Boolean endAction) (at Assets/Imported/CrashKonijn/GOAP/Runtime/CrashKonijn.Goap/Behaviours/AgentBehaviour.cs:181)
AgentBrain.Start () (at Assets/Scripts/AgentBrain.cs:15)

I believe that I configured everything else correctly, but please let me know if there is anything I should check specifically.

Steps to Reproduce
Steps to reproduce the behavior:

  1. Import asset from Unity through the Package Manager.
  2. Follow the tutorial.
  3. Add the imported AgentBehaviour component to agent.
  4. Press play.

Expected behavior
The agent should wander without any specific goal.

Unity Version
2022.3.9f1

Unity.Collections Version
Please mention the Unity.Collections version you are using.

Package Version
Please mention the package version you are using.

Additional context
It might be worth it to mention that I'm using this in a 3D project, so the Agent GameObject also has a NavMeshAgent. I've tried running with it both on and off.

Thank you for your hard work! This documentation has been amazing thus far (even if I haven't quite gotten this to work yet).

Bug: Don't traverse other conditions of an action of one of it's conditions doesn't have a connected action

Describe the bug
When traversing the action graph to find a valid action to perform the resolver doesn't perform a 'full tree search' to see if ALL conditions could be met. Right now the system will just find any action that it can perform towards a goal, for any condition that isn't met in the tree.

There can be cases where a condition could be present in the world state, but where there's no action that could influence that particular world state.

Lets say you spawn an enemy with a random weapon which they cannot change. The ShootBowAction is not something that you'd like it to consider. You'd also not want it to PickupArrows. If the HasBow condition is false, it should no traverse any other conditions.

Describe the solution you'd like
If an action contains any (false) condition without connected actions that could change it to true, skip this action.

Question: How to implement local sensor for moving object?

Current behavior
I have a "playerTargetSensor" script that takes the position of a player. I have an agent that walks up to the player and performs the desired action.

A problem arises when the player moves around the scene.

Lets say the player goes from position 1 to position 2. It starts at position 1 when it the scene begins, then goes to position 2 after a second.

The agent moves to position 1 always, even if the player is moving towards position 2. I do not want this behavior because I don't want the agent to the past position, I want them to move to the current position.

Desired behavior
If an agent is tracking a player, they should be able to see where the player is located, and simply move there.

The sensor could have a function called "checkTargetPositionEvery3Seconds", and if the target position changes during those 3 seconds, it should be able to recalculate where to go.

Due to performance concerns, we could also have the ability to have it based on a timer (so the position gets updated every 2 seconds rather than once a frame).

Work done to find a potential solution

I've tried editing AgentMoveBehaviour to reset the ITarget if the player moves, but I haven't had much progress with that just yet. Still working on it. I think I'm going to look at the AgentBehaviour script and try to call the UpdateTarget() function. Right now, it looks like I kind of have to move around and modify either the AgentMoveBehaviour or AgentBehaviour script. I'd prefer if it was possible to just edit the sensor for the player target instead of trying to manually reset the target.

I've also tried asking the gitbooks AI, however it isn't really clear if they want me to edit the sensor file itself, or one of the agentbehaviour scripts.

Bug: Editor Console states memory leak at start (rare) or after exiting play mode (often)

System is Windows 11, i7-6700, GTX9800ti with 16GBytes of RAM
Unity version is 2022.3.0f1
Using URP
No other asset except GOAP (store version 2.1.5) is imported to project
Unity.Collections Version 1.2.4

Not always reproducible, but more likely to happen when CPU is stressed.

Attempting to test performance with more agents, the following is added to Start() of AgentSpawnBehaviour.cs for the Complex Demo scene:

for (int i = 0; i < 200; i++) {
this.SpawnAgent(SetIds.Cleaner, ComplexAgentBrain.AgentType.Cleaner, this.cleanerColor);
}

The following error is only observed once at start:

Leak Detected : TempJob allocates 4 individual allocations. To find out more please enable 'Jobs/LeakDetection/Full StackTraces' and reproduce the leak again.

After in play mode for one or 2 minutes, exit the play mode.
The following happens often after exiting play mode:

ObjectDisposedException: The Unity.Collections.NativeList1[CrashKonijn.Goap.Resolver.NodeData] has been deallocated, it is not allowed to access it Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckGetSecondaryDataPointerAndThrow (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) (at <6c9b376c3fca40b787e8c1a2133bf243>:0) Unity.Collections.NativeList1[T].AsArray () (at ./Library/PackageCache/[email protected]/Unity.Collections/NativeList.cs:607)
Unity.Collections.NativeList`1[T].GetEnumerator () (at ./Library/PackageCache/[email protected]/Unity.Collections/NativeList.cs:743)
CrashKonijn.Goap.Resolver.ResolveHandle.Complete () (at Assets/CrashKonijn/GOAP/Runtime/CrashKonijn.Goap.Resolver/ResolveHandle.cs:51)
CrashKonijn.Goap.Classes.Runners.GoapSetJobRunner.Dispose () (at Assets/CrashKonijn/GOAP/Runtime/CrashKonijn.Goap/Classes/Runners/GoapSetJobRunner.cs:146)
CrashKonijn.Goap.Classes.Runners.GoapRunner.Dispose () (at Assets/CrashKonijn/GOAP/Runtime/CrashKonijn.Goap/Classes/Runners/GoapRunner.cs:53)
CrashKonijn.Goap.Behaviours.GoapRunnerBehaviour.OnDestroy () (at Assets/CrashKonijn/GOAP/Runtime/CrashKonijn.Goap/Behaviours/GoapRunnerBehaviour.cs:56)

The above error is followed by the error below multiple times:

A Native Collection has not been disposed, resulting in a memory leak. Enable Full StackTraces to get more details. Leak tracking may be enabled via Unity.Collections.NativeLeakDetection.Mode or from the editor preferences menu Edit > Preferences > Jobs > Leak Detection Level.

The following are probably due to lack of null check, so may not be related to the issue stated above, but happens within same tests:

NullReferenceException: Object reference not set to an instance of an object
Demos.Complex.Actions.HaulItemAction.Start (CrashKonijn.Goap.Interfaces.IMonoAgent agent, Demos.Complex.Actions.HaulItemAction+Data data) (at Assets/CrashKonijn/GOAP/Demos/Complex/Actions/HaulItemAction.cs:32)
CrashKonijn.Goap.Behaviours.ActionBase1[TActionData].Start (CrashKonijn.Goap.Interfaces.IMonoAgent agent, CrashKonijn.Goap.Interfaces.IActionData data) (at Assets/CrashKonijn/GOAP/Runtime/CrashKonijn.Goap/Behaviours/ActionBase.cs:25) CrashKonijn.Goap.Behaviours.AgentBehaviour.SetAction (CrashKonijn.Goap.Interfaces.IActionBase action, System.Collections.Generic.List1[T] path, CrashKonijn.Goap.Interfaces.ITarget target) (at Assets/CrashKonijn/GOAP/Runtime/CrashKonijn.Goap/Behaviours/AgentBehaviour.cs:212)
CrashKonijn.Goap.Classes.Runners.GoapSetJobRunner.Complete () (at Assets/CrashKonijn/GOAP/Runtime/CrashKonijn.Goap/Classes/Runners/GoapSetJobRunner.cs:138)
CrashKonijn.Goap.Classes.Runners.GoapRunner.Complete () (at Assets/CrashKonijn/GOAP/Runtime/CrashKonijn.Goap/Classes/Runners/GoapRunner.cs:43)
CrashKonijn.Goap.Behaviours.GoapRunnerBehaviour.LateUpdate () (at Assets/CrashKonijn/GOAP/Runtime/CrashKonijn.Goap/Behaviours/GoapRunnerBehaviour.cs:51)

NullReferenceException: Object reference not set to an instance of an object
Demos.Complex.Actions.HaulItemAction.MoveToItem (CrashKonijn.Goap.Interfaces.IMonoAgent agent, Demos.Complex.Actions.HaulItemAction+Data data) (at Assets/CrashKonijn/GOAP/Demos/Complex/Actions/HaulItemAction.cs:58)
Demos.Complex.Actions.HaulItemAction.Perform (CrashKonijn.Goap.Interfaces.IMonoAgent agent, Demos.Complex.Actions.HaulItemAction+Data data, CrashKonijn.Goap.Classes.ActionContext context) (at Assets/CrashKonijn/GOAP/Demos/Complex/Actions/HaulItemAction.cs:44)
CrashKonijn.Goap.Behaviours.ActionBase`1[TActionData].Perform (CrashKonijn.Goap.Interfaces.IMonoAgent agent, CrashKonijn.Goap.Interfaces.IActionData data, CrashKonijn.Goap.Classes.ActionContext context) (at Assets/CrashKonijn/GOAP/Runtime/CrashKonijn.Goap/Behaviours/ActionBase.cs:29)
CrashKonijn.Goap.Behaviours.AgentBehaviour.PerformAction () (at Assets/CrashKonijn/GOAP/Runtime/CrashKonijn.Goap/Behaviours/AgentBehaviour.cs:155)
CrashKonijn.Goap.Behaviours.AgentBehaviour.RunMoveBeforePerforming () (at Assets/CrashKonijn/GOAP/Runtime/CrashKonijn.Goap/Behaviours/AgentBehaviour.cs:104)
CrashKonijn.Goap.Behaviours.AgentBehaviour.Run () (at Assets/CrashKonijn/GOAP/Runtime/CrashKonijn.Goap/Behaviours/AgentBehaviour.cs:74)
CrashKonijn.Goap.Classes.Runners.GoapRunner.Run () (at Assets/CrashKonijn/GOAP/Runtime/CrashKonijn.Goap/Classes/Runners/GoapRunner.cs:33)
CrashKonijn.Goap.Behaviours.GoapRunnerBehaviour.Update () (at Assets/CrashKonijn/GOAP/Runtime/CrashKonijn.Goap/Behaviours/GoapRunnerBehaviour.cs:46)

Feature: references.GetComponentInParent

Is your feature request related to a problem? Please describe.
LocalWorldSensor class does not allow to grab a component from the parent object when using the references. Only from the agent.

public override SenseValue Sense(IMonoAgent agent, IComponentReference references)
{

    return (int)references.GetComponentInParent<BunnyData>().RestFactor;
}

Describe the solution you'd like
You've asked me to write this up to potentially add this functionality

Describe alternatives you've considered
Maybe provide entry level documentation on how to properly use references the way it was originally intended

Additional context
image

Question: Why ComplexAgentBrain.class need handle the Goal?

Why isn't this code written in the plan? Need to be dealt with separately?

    private void UpdateHunger()
    {
        if (this.hunger.hunger > 80)
        {
            this.agent.SetGoal<FixHungerGoal>(false);
            return;
        }

        if (this.agent.CurrentGoal is not FixHungerGoal)
            return;
        
        if (this.hunger.hunger < 20)
            this.DetermineGoal();
    }

    private void DetermineGoal()
    {
        switch (this.agentType)
        {
            case AgentType.Miner:
                this.DetermineMinerGoals();
                break;
            case AgentType.WoodCutter:
                this.DetermineWoodCutterGoals();
                break;
            case AgentType.Smith:
                this.DetermineSmithGoals();
                break;
            case AgentType.Cleaner:
                this.DetermineCleanerGoals();
                break;
        }
    }

Add ability to add IWorldKey and ITargetKey to GoapSetBuilder

When creating the configuration through ScriptableObjects you have to actually create the IWorldKey and ITargetKey objects and use them in the correct spots during setup.

In the setup through code this is abstracted to string keys, which makes it less obvious what's happening. I propose changing the setup to require actual classes of both types being created and used. This should be more type safe and make it more obvious what they are instead of using both of them as strings.

This is a breaking change, so this can be implemented for 2.1.0 (which is already breaking).

Move events

The current move implementation doesn't give any information about when movement is started or stopped. This makes it quite hard to implement something like the NavMeshAgent.

I propose changing the IAgentMover to a couple events: OnTargetChanged, OnMove, OnTargetReached and OnMoveStop.

GoapGoal has no children

Following your examples, I tried a two way movement system by first checking then path then moving, but unfortunately the GoapState appears without any of its set children. The code for adding something to the goal is as below. Since this is a testing example, neither FindMovement nor MoveToPosition entails each other.

`possibleActions.Add(findMovement);
possibleActions.Add(moveToPosition);

    AddAction(findMovement);
    AddAction(moveToPosition);

    changePositionActions.Add(findMovement);
    changePositionActions.Add(moveToPosition);

    changePosition.SetChilds(changePositionActions);

    goals.Add(GoapGoal.Goals.CHANGE_POSITION, changePosition);`

Any idea why ?

Feature: Keep WorldKeyBuilder to query the keys

Is your feature request related to a problem? Please describe.
The WorldKeyBuilder is lost after the GoapSetBuilder is built. I'd like to query the agent.WorldData.IsTrue by using generics, and in order for me to do that we need an instance of the key which doesn't seem possible due to the lost WorldKeyBuilder.

The purpose of this is for the brain to be able to query the world state (maybe even the global?) to choose the best Goal in the current state.

Describe the solution you'd like
It would be preferable to have access to the WorldKeyBuilder, alternativley be able to do something like agent.WorldData.IsTrue<IsHungry>(...). I know WorldData.States exists but looping over it is O(n) instead of O(1).

Bug: Nodeviewer doesn't display/displays inconsistently

Describe the bug
When working with custom goap set config factories, the node viewer sometimes does not appear.

Steps to Reproduce
Steps to reproduce the behavior:

  1. Create custom goap set config factory, add custom actions/scripts
  2. The first time you run a scene to look at the node viewer, the planner graph appears just fine and shows up
  3. The second time you run a scene, the planer graph does not appear

Expected behavior
When I click the node viewer, I expect the planner graph to show up.

Screenshots
Node
image
image

Unity Version
2022.3.9f1

Unity.Collections Version
1.2.4
Package Version
2.1.8

Additional context
This problem is easily fixed whenever I restart the editor. There are no error messages that appear. I'm not sure what causes it.

Would it help if I uploaded my files?

Feature: Set distance multiplier on an agent

Assumption: In general the best actions to perform are the fastest way to reach a goal. In that case the cost of an action is probably equal to the time for it to complete. If that's the case than the distance value used in the heuristics should probably be divided by the move speed of an agent as well.

Suggestion: Add a distance multiplier option to an agent. (each agent might have different speeds).

Thanks @SiliconOrchid for the idea!

Bug: Local Sensor Not Called

Describe the bug
Local World Sensor is not updated, and the main action stalls. The sensor is never called. In the Screenshot below the action is ShootAction and the key is InCooldown. The InCooldown is updated per update, but for some reason even the sensor's Sense method is not called.

Steps to Reproduce
Steps to reproduce the behavior:

  1. Change the local sensor value from the outsdie.
  2. Action has an old sensor value and it stalls.

Expected behavior
The local world sensor should update even even if there are no current actions.

Screenshots
image

Unity Version
2022.2.8f

Package Version
2.1.5

Additional context
Add any other context about the problem here.

I'm back baby!

Hi all,

First of all I'd like to thank everyone that has taken an interest to this project over the years!

After doing this as my graduation project back in 2016 I unfortunately didn't end up working in games and with that I didn't have the energy to put more effort into this project. Luckily I have been working as a .NET developer so my relevant coding experience did increase ✌

The last year I've started doing some private game dev to get back into the game πŸ•Ή and for my latest project I started rebuilding a GOAP from scratch!

So far the project is composed of two separate projects:

  • A "Pure" GOAP written in C#. It knows nothing of unity and is only the node navigator in it's purest sense.
  • The Unity implementation of the above mentioned package including debug windows, editors and configuration through scriptable objects!

Features

So this is what I've got going so far:

  • Goals
  • Actions
  • Sensors (A proper example was lacking in the 2016 version)
  • Easy setup through scriptable objects
  • Proper abstractions
  • Proper demo
  • Basic versions of debug windows
  • Tests (partially)
  • Packaging it as a unity package
  • Running tests in a pipeline
  • Proper test coverage
  • Cleaning code
  • Documentation

Notes:

  • The debug windows are in somewhat rough state still (code wise) and still require some proper cleaning
  • It's not multithreaded (for now)

Help

If you'd like to get involved in the development or can help with the packaging or pipeline please let me know!

Sneak preview:

image
image
image
image
image
image

HAS_OBJECT Not updating

As i was running the example and trying to edit it a little bit, i found that even though the AI are moving to the 'throwable' and preforming the action of 'GrabItem', HAS_OBJECT doesn't ever get set to true. I was hoping you could point me in the right direction as to how or where this is supposed to update the variable from the "Effects" so that it becomes true.

Thank you!

Feature: Allow to manually re-queue agent

Is your feature request related to a problem? Please describe.
Currently it is not possible to force the re-running of the GOAP for an agent. I'd like to make this possible so you can let the GOAP check if the currently running action still is the best action.

Describe the solution you'd like

// Pseudo code
class ReRunBehaviour : MonoBehaviour {
    private AgentBehaviour agent;

    private void Awake() {
        this.agent = this.GetComponent<AgentBehaviour>();
    }

    private void Update() {
        // Best to probably check this once every 0.5 sec or something instead of every frame
        this.agent.GoapSet.Agents.Enqueue(this.agent)
    }
}

Feature: Unit Tests for Goal Completion

Is your feature request related to a problem? Please describe.
I think there might be a bug where OnGoalCompleted is never called, but I'm not sure if its me or the underlying systems. It would be nice to have a Unit Test to reference how I should be setting up my system so that I receive OnGoalCompleted correctly.

Describe the solution you'd like
A Unit Test that makes sure that, given a goal with a condition, and an action that modifies state to meet that condition, goal completion logic is reached.

Describe alternatives you've considered
I considered just asking about this in the discord, but it would be better to have a code solution to prevent people from continuously asking in the future. I also considered making a bug about this, but I'm not familiar enough with the innards of this project to confidently say that I'm seeing a bug.

Additional context
The Complex Example has the brain listen for OnGoalCompleted, but if you put a breakpoint on it, it never seems to be hit.

Feature: Check for action conditions while the action is running

Is your feature request related to a problem? Please describe.
Currently the conditions of an action aren't checked once an action is running. It would be better (and fairly optimized) to include this in the system.

Describe the solution you'd like
We could loop through each condition and only update the sensors required for that action.

Additional context
I'd like to introduce an extra method to an action: Completed. This would differentiate between when an action is completed, or stopped externally. Both could require different logic to be applied.

Problems when importing from git

I wanted to add the package via "Add package from git URL" in the package manager, but all the README.md files don't have a meta file which throws several errors and the asset will be ignored. Would be nice if you could add them.

Example output:
Asset Packages/com.crashkonijn.goap/Documentation/Classes/README.md has no meta file, but it's in an immutable folder. The asset will be ignored.

Also this warning appears:
Packages/com.crashkonijn.goap/Editor/CrashKonijn.Goap.Editor/Styles/NodeViewer.uss (line 36): warning: Unknown property 'weight' (did you mean 'height'?)
weight: 100

Issue: Node Viewer Breaks Second Time You Play

When I play the editor (2022.2.8f1) for the first time the Node Viewer show the agent fine and when I click on it the tree works as intended.
The issue is when I start the game again, the agent is listed, but when I click on it the action tree doesn't show up.
image

Getting started guide not working

Hi, I just grabbed the new version and I'm following the getting started guide using ScriptableObjects in Unity 2022.2.14f1. GoapSet.ResolveGoal is throwing a KeyNotFoundException when I enter play mode. From stepping through the code, it appears that ClassResolver.Load is discarding my action and goal because their ClassType property is an empty string. Is there an additional step I need to take?

Unity Crash when run demo

Hi @crashkonijn
I found this project and it is really awesome! I like this so much and I think can apply this to make some funny bots for my game.
Recently, when I run the demo on a Macbook Pro, chip M1 Max, Unity 2022.2.11f1 Silicon version
The Editor Crash and the log is like this

Obtained 91 stack frames.
#0  0x00000100bde960 in ScriptableRenderLoopShadowsJob(GfxDeviceAsyncCommand::ArgScratch*, GfxDeviceAsyncCommand::Arg const*)
#1  0x00000100f3d7a4 in GfxDevice::ExecuteAsync(int, void (*)(GfxDeviceAsyncCommand::ArgScratch*, GfxDeviceAsyncCommand::Arg const*), GfxDeviceAsyncCommand::ArgScratch**, GfxDeviceAsyncCommand::Arg const*, JobFence const&)
#2  0x00000100bd5c20 in ScheduleRenderJobs(unsigned int, ScriptableRenderLoopShadowsArg const*, JobFence const&)
#3  0x00000100bd5828 in ExecuteDrawShadowsCommand(SlicedDrawShadow const&)
#4  0x00000100bdb734 in ScriptableRenderContext::ExecuteScriptableRenderLoop()
#5  0x0000035d1d4774 in  (wrapper managed-to-native) UnityEngine.Rendering.ScriptableRenderContext:Submit_Internal_Injected (UnityEngine.Rendering.ScriptableRenderContext&) [{0x3276be998} + 0xa4]  (0x35d1d46d0 0x35d1d4808) [0x12ff96a80 - Unity Child Domain]
#6  0x0000035d1d4664 in  UnityEngine.Rendering.ScriptableRenderContext:Submit_Internal () [{0x3276be8b0} + 0x3c]  (0x35d1d4628 0x35d1d4680) [0x12ff96a80 - Unity Child Domain]
#7  0x0000035d1d45a0 in  UnityEngine.Rendering.ScriptableRenderContext:Submit () [{0x3276294b0} + 0x78] [/Users/bokken/build/output/unity/unity/Runtime/Export/RenderPipeline/ScriptableRenderContext.cs :: 117u] (0x35d1d4528 0x35d1d45c8) [0x12ff96a80 - Unity Child Domain]
#8  0x0000035d11353c in  UnityEngine.Rendering.Universal.UniversalRenderPipeline:RenderSingleCamera (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Rendering.Universal.CameraData&,bool) [{0x3275f4ad0} + 0x1014] [./Library/PackageCache/[email protected]/Runtime/UniversalRenderPipeline.cs :: 657u] (0x35d112528 0x35d113604) [0x12ff96a80 - Unity Child Domain]
#9  0x0000035d107eb4 in  UnityEngine.Rendering.Universal.UniversalRenderPipeline:RenderSingleCameraInternal (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera) [{0x3275f4758} + 0x2a4] [./Library/PackageCache/[email protected]/Runtime/UniversalRenderPipeline.cs :: 527u] (0x35d107c10 0x35d107f00) [0x12ff96a80 - Unity Child Domain]
#10 0x0000035d0f4704 in  UnityEngine.Rendering.Universal.UniversalRenderPipeline:Render (UnityEngine.Rendering.ScriptableRenderContext,System.Collections.Generic.List`1<UnityEngine.Camera>) [{0x348d4e710} + 0x8dc] [./Library/PackageCache/[email protected]/Runtime/UniversalRenderPipeline.cs :: 369u] (0x35d0f3e28 0x35d0f4b14) [0x12ff96a80 - Unity Child Domain]
#11 0x0000035d0f3654 in  UnityEngine.Rendering.RenderPipeline:InternalRender (UnityEngine.Rendering.ScriptableRenderContext,System.Collections.Generic.List`1<UnityEngine.Camera>) [{0x2ec0c2a98} + 0x154] [/Users/bokken/build/output/unity/unity/Runtime/Export/RenderPipeline/RenderPipeline.cs :: 52u] (0x35d0f3500 0x35d0f367c) [0x12ff96a80 - Unity Child Domain]
#12 0x0000035d052308 in  UnityEngine.Rendering.RenderPipelineManager:DoRenderLoop_Internal (UnityEngine.Rendering.RenderPipelineAsset,intptr,UnityEngine.Object,Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle) [{0x2ecb4f8b8} + 0x220] [/Users/bokken/build/output/unity/unity/Runtime/Export/RenderPipeline/RenderPipelineManager.cs :: 126u] (0x35d0520e8 0x35d052448) [0x12ff96a80 - Unity Child Domain]
#13 0x0000035d0527b4 in  (wrapper runtime-invoke) <Module>:runtime_invoke_void_object_intptr_object_AtomicSafetyHandle (object,intptr,intptr,intptr) [{0x2ec0c2c80} + 0x12c]  (0x35d052688 0x35d0528dc) [0x12ff96a80 - Unity Child Domain]
#14 0x0000016b094884 in mono_jit_runtime_invoke
#15 0x0000016b21b480 in do_runtime_invoke
#16 0x0000016b21b3a0 in mono_runtime_invoke
#17 0x0000010103fc34 in scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool)
#18 0x0000010101ee40 in ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool)
#19 0x00000100bdcb74 in ScriptableRenderContext::ExtractAndExecuteRenderPipeline(dynamic_array<Camera*, 0ul> const&, void (*)(SceneNode const*, AABB const*, IndexList&, SceneCullingParameters const*), void*, ScriptingObjectPtr)
#20 0x00000102cf2ed8 in Camera::ExecuteCustomRenderPipeline(Camera::EditorDrawingMode, DrawGridParameters const*, Camera::RenderFlag, core::hash_set<int, core::hash<int>, std::__1::equal_to<int> > const&, core::hash_set<int, core::hash<int>, std::__1::equal_to<int> > const&, ColorRGBAf, ColorRGBAf, float, float, int, Camera::OutlineDrawMode)
#21 0x00000102cf3b18 in Camera::RenderEditorCamera(Camera::EditorDrawingMode, DrawGridParameters const*, CullResults*, Camera::RenderFlag, int, bool, bool, core::hash_set<int, core::hash<int>, std::__1::equal_to<int> > const&, core::hash_set<int, core::hash<int>, std::__1::equal_to<int> > const&, core::hash_set<GameObject*, core::hash<GameObject*>, std::__1::equal_to<GameObject*> >*, ColorRGBAf, ColorRGBAf, float, float, int, Camera::OutlineDrawMode)
#22 0x00000102cf5758 in Camera::RenderEditorCamera(Camera::EditorDrawingMode, DrawGridParameters const*, bool, bool, core::hash_set<GameObject*, core::hash<GameObject*>, std::__1::equal_to<GameObject*> >*, CullResults*, std::__1::set<GameObject*, std::__1::less<GameObject*>, stl_allocator<GameObject*, (MemLabelIdentifier)1, 16> >*, ColorRGBAf, ColorRGBAf, float, float, int, Camera::OutlineDrawMode)
#23 0x000001006e1fb4 in Handles_CUSTOM_Internal_DrawCameraWithGrid(ScriptingBackendNativeObjectPtrOpaque*, Camera::EditorDrawingMode, DrawGridParameters&, unsigned char, unsigned char)
#24 0x0000035d05200c in  (wrapper managed-to-native) UnityEditor.Handles:Internal_DrawCameraWithGrid (UnityEngine.Camera,UnityEditor.DrawCameraMode,UnityEditor.DrawGridParameters&,bool,bool) [{0x327455e20} + 0xe4]  (0x35d051f28 0x35d052094) [0x12ff96a80 - Unity Child Domain]
#25 0x0000035d039648 in  UnityEditor.Handles:DrawCameraImpl (UnityEngine.Rect,UnityEngine.Camera,UnityEditor.DrawCameraMode,bool,UnityEditor.DrawGridParameters,bool,bool,bool,UnityEngine.GameObject[]) [{0x327455c88} + 0x6a8] [/Users/bokken/build/output/unity/unity/Editor/Mono/Handles.cs :: 1594u] (0x35d038fa0 0x35d0397bc) [0x12ff96a80 - Unity Child Domain]
#26 0x0000035d038f28 in  UnityEditor.Handles:DrawCameraStep1 (UnityEngine.Rect,UnityEngine.Camera,UnityEditor.DrawCameraMode,UnityEditor.DrawGridParameters,bool,bool) [{0x327455580} + 0x188] [/Users/bokken/build/output/unity/unity/Editor/Mono/Handles.cs :: 1617u] (0x35d038da0 0x35d038f4c) [0x12ff96a80 - Unity Child Domain]
#27 0x0000035d033ee0 in  UnityEditor.SceneView:DoDrawCamera (UnityEngine.Rect,UnityEngine.Rect,bool&) [{0x1276a3100} + 0xdc8] [/Users/bokken/build/output/unity/unity/Editor/Mono/SceneView/SceneView.cs :: 2096u] (0x35d033118 0x35d0347dc) [0x12ff96a80 - Unity Child Domain]
#28 0x0000035d00cad4 in  UnityEditor.SceneView:DoOnGUI () [{0x1276a32b8} + 0x1254] [/Users/bokken/build/output/unity/unity/Editor/Mono/SceneView/SceneView.cs :: 2415u] (0x35d00b880 0x35d00e1e4) [0x12ff96a80 - Unity Child Domain]
#29 0x0000035d00b814 in  UnityEditor.SceneView:OnSceneGUI () [{0x1276a3290} + 0x54] [/Users/bokken/build/output/unity/unity/Editor/Mono/SceneView/SceneView.cs :: 2328u] (0x35d00b7c0 0x35d00b830) [0x12ff96a80 - Unity Child Domain]
#30 0x0000035c4cb5e8 in  UnityEngine.UIElements.IMGUIContainer:DoOnGUI (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,bool,UnityEngine.Rect,System.Action,bool) [{0x17bfb3008} + 0xe50] [/Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/IMGUIContainer.cs :: 355u] (0x35c4ca798 0x35c4ccbd8) [0x12ff96a80 - Unity Child Domain]
#31 0x0000035c4a8dc8 in  UnityEngine.UIElements.IMGUIContainer:HandleIMGUIEvent (UnityEngine.Event,UnityEngine.Matrix4x4,UnityEngine.Rect,System.Action,bool) [{0x17bfb3210} + 0x6d8] [/Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/IMGUIContainer.cs :: 676u] (0x35c4a86f0 0x35c4a9104) [0x12ff96a80 - Unity Child Domain]
#32 0x0000035ceeaf24 in  UnityEngine.UIElements.IMGUIContainer:DoIMGUIRepaint () [{0x17bfb3080} + 0x514] [/Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/IMGUIContainer.cs :: 536u] (0x35ceeaa10 0x35ceeafa8) [0x12ff96a80 - Unity Child Domain]
#33 0x0000035cee86bc in  UnityEngine.UIElements.UIR.RenderChainCommand:ExecuteNonDrawMesh (UnityEngine.UIElements.UIR.DrawParams,single,System.Exception&) [{0x2ec07fff8} + 0x6bc] [/Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Renderer/UIRenderer/UIRenderers.cs :: 130u] (0x35cee8000 0x35cee9c1c) [0x12ff96a80 - Unity Child Domain]
#34 0x0000035ced6c00 in  UnityEngine.UIElements.UIR.UIRenderDevice:EvaluateChain (UnityEngine.UIElements.UIR.RenderChainCommand,UnityEngine.Material,UnityEngine.Material,UnityEngine.Texture,UnityEngine.Texture,single,Unity.Collections.NativeSlice`1<UnityEngine.UIElements.UIR.Transform3x4>,Unity.Collections.NativeSlice`1<UnityEngine.Vector4>,UnityEngine.MaterialPropertyBlock,bool,System.Exception&) [{0x2ec07f978} + 0x1710] [/Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Renderer/UIRenderer/UIRenderDevice.cs :: 1003u] (0x35ced54f0 0x35ced71e4) [0x12ff96a80 - Unity Child Domain]
#35 0x0000035ced1c40 in  UnityEngine.UIElements.UIR.RenderChain:Render () [{0x2ec0ee2a0} + 0x738] [/Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Renderer/UIRRenderChain.cs :: 500u] (0x35ced1508 0x35ced1ddc) [0x12ff96a80 - Unity Child Domain]
#36 0x0000035cdad0fc in  UnityEngine.UIElements.UIRRepaintUpdater:Update () [{0x328058bb0} + 0x474] [/Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Renderer/UIRRepaintUpdater.cs :: 79u] (0x35cdacc88 0x35cdad13c) [0x12ff96a80 - Unity Child Domain]
#37 0x0000035c45c04c in  UnityEngine.UIElements.VisualTreeUpdater:UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase) [{0x2ec1b9880} + 0x174] [/Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/VisualTreeUpdater.cs :: 111u] (0x35c45bed8 0x35c45c0c0) [0x12ff96a80 - Unity Child Domain]
#38 0x0000035cd30368 in  UnityEngine.UIElements.Panel:UpdateForRepaint () [{0x2b2fd8668} + 0x110] [/Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Panel.cs :: 1012u] (0x35cd30258 0x35cd30390) [0x12ff96a80 - Unity Child Domain]
#39 0x0000035cd2d8e0 in  UnityEngine.UIElements.Panel:Repaint (UnityEngine.Event) [{0x2ccc005f0} + 0x330] [/Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/Panel.cs :: 1073u] (0x35cd2d5b0 0x35cd2d9e8) [0x12ff96a80 - Unity Child Domain]
#40 0x0000035c45b100 in  UnityEngine.UIElements.UIElementsUtility:DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel) [{0x2ec1b97a0} + 0x278] [/Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/UIElementsUtility.cs :: 454u] (0x35c45ae88 0x35c45b760) [0x12ff96a80 - Unity Child Domain]
#41 0x0000035c45ab5c in  UnityEngine.UIElements.UIElementsUtility:UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (int,intptr,bool&) [{0x2b2f044a0} + 0x1b4] [/Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/UIElementsUtility.cs :: 205u] (0x35c45a9a8 0x35c45abf8) [0x12ff96a80 - Unity Child Domain]
#42 0x0000035c45a6ac in  UnityEngine.UIElements.UIEventRegistration:ProcessEvent (int,intptr) [{0x2ec1b96e0} + 0x194] [/Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/UIElementsUtility.cs :: 74u] (0x35c45a518 0x35c45a824) [0x12ff96a80 - Unity Child Domain]
#43 0x0000035c45a488 in  UnityEngine.UIElements.UIEventRegistration/<>c:<.cctor>b__1_2 (int,intptr) [{0x2b2f050c8} + 0x70] [/Users/bokken/build/output/unity/unity/ModuleOverrides/com.unity.ui/Core/UIElementsUtility.cs :: 28u] (0x35c45a418 0x35c45a4c4) [0x12ff96a80 - Unity Child Domain]
#44 0x0000035c45a1a0 in  UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) [{0x1276027a0} + 0xe0] [/Users/bokken/build/output/unity/unity/Modules/IMGUI/GUIUtility.cs :: 189u] (0x35c45a0c0 0x35c45a1f4) [0x12ff96a80 - Unity Child Domain]
#45 0x0000035c45a2e8 in  (wrapper runtime-invoke) <Module>:runtime_invoke_void_int_intptr_intptr& (object,intptr,intptr,intptr) [{0x2ec449450} + 0xf0]  (0x35c45a1f8 0x35c45a3d4) [0x12ff96a80 - Unity Child Domain]
#46 0x0000016b094884 in mono_jit_runtime_invoke
#47 0x0000016b21b480 in do_runtime_invoke
#48 0x0000016b21b3a0 in mono_runtime_invoke
#49 0x0000010103fc34 in scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool)
#50 0x0000010101ee40 in ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool)
#51 0x0000010115429c in Scripting::UnityEngine::GUIUtilityProxy::ProcessEvent(int, void*, bool*, ScriptingExceptionPtr*)
#52 0x00000101a4162c in GUIView::ProcessRetainedMode(InputEvent&, GUIState&, int)
#53 0x00000102e39850 in GUIView::OnInputEvent(InputEvent&)
#54 0x00000101a40ae4 in GUIView::ProcessInputEvent(InputEvent&)
#55 0x00000102e48ba8 in -[GUIRenderView renderRect:]
#56 0x00000102e46694 in -[GUIMetalView drawRect:]
#57 0x00000102e3b29c in GUIView::DoPaint()
#58 0x00000102e3b548 in GUIView::RepaintAll(bool)
#59 0x00000101b9f134 in PlayerLoopController::InternalUpdateScene(bool, bool)
#60 0x00000101b9779c in PlayerLoopController::UpdateSceneIfNeededFromMainLoop()
#61 0x00000101b94e18 in Application::TickTimer()
#62 0x00000102e26c94 in -[EditorApplication TickTimer]
#63 0x000001b08fb44c in __NSFireTimer
#64 0xba498001af9d354c in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__
#65 0x4b6e8001af9d31f4 in __CFRunLoopDoTimer
#66 0x3000001af9d2d4c in __CFRunLoopDoTimers
#67 0x8d6c8001af9b8734 in __CFRunLoopRun
#68 0xec770001af9b7878 in CFRunLoopRunSpecific
#69 0x2b3c8001b9097fa0 in RunCurrentEventLoopInMode
#70 0xc7020001b9097de4 in ReceiveNextEventCommon
#71 0x21400001b9097b2c in _BlockUntilNextEventMatchingListInModeWithFilter
#72 0x4b210001b2c3d84c in _DPSNextEvent
#73 0xf9620001b2c3c9dc in -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]
#74 0x8671800102e26aec in -[EditorApplication checkForFocusChange:]
#75 0x000001b08fb44c in __NSFireTimer
#76 0xa5640001af9d354c in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__
#77 0x9d490001af9d31f4 in __CFRunLoopDoTimer
#78 0xb0048001af9d2d4c in __CFRunLoopDoTimers
#79 0xa8748001af9b8734 in __CFRunLoopRun
#80 0x7e570001af9b7878 in CFRunLoopRunSpecific
#81 0x5f288001b9097fa0 in RunCurrentEventLoopInMode
#82 0x417d8001b9097de4 in ReceiveNextEventCommon
#83 0xa34e8001b9097b2c in _BlockUntilNextEventMatchingListInModeWithFilter
#84 0xf760001b2c3d84c in _DPSNextEvent
#85 0x7b080001b2c3c9dc in -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:]
#86 0x3008001b2c30e0c in -[NSApplication run]
#87 0x141d0001b2c08250 in NSApplicationMain
#88 0xc45b800102e3f510 in EditorMain(int, char const**)
#89 0x00000102e3f84c in main
#90 0x000001af5afe50 in start

Issue: Remove warnings from project

There are various warnings in the project, they should be removed.

Package\Editor\CrashKonijn.Goap.Editor\NodeViewer\NodeViewerEditorWindow.cs(22,23): warning CS0414: The field 'NodeViewerEditorWindow.lastUpdate' is assigned but its value is never used

Script 'Tree' has the same name as built-in Unity component. AddComponent and GetComponent will not work with this script.

Feature: Reference classes in configs in a more robust way

Is your feature request related to a problem? Please describe.
When setting up your GOAP through SO you have to reference a fully qualified class. When renaming or moving classes you lose this reference.

Describe the solution you'd like
I'd like to introduce specific attributes which contains an ID for a class. This should be referenced instead.

[ActionId("198c33c2-7fa5-4a77-8b55-9baf06f3cdb5")]
public class ExampleAction : ActionBase {}

On Perform end event

Hello, thanks for implementation GOAP, how i can get Perform "start" and "end" event from GOAP action?

I want Play animation on Perform start and disable this on Perform end.

Feature: Add ability to sense multiple world/target keys from a single class

Is your feature request related to a problem? Please describe.
Having to create a lot of sensor classes is a lot of work. Using the setup through code method one might be able to abstract this to something relatively simple, but using SO's this is not possible.

Describe the solution you'd like
There should be a way to create a 'multi sensor'. For example something like this:

// Pseudo code
class MultiSensor {
    private AppleItem[] apples = Array.Empty<AppleItem>();

    public void Update() {
        // cache data that's for all agents in this set
        this.apples = GameObject.FindObjectsOfType<AppleItem>()
    }

    public void Initialize() {
        this.addLocalWorldSensor<Health>((agent, references) => {
            return references.GetCachedComponent<HealthBehaviour>.health;
        })

        this.addLocalWorldSensor<HasApple>((agent, references) => {
            return references.GetCachedComponent<InventoryBehaviour>.has<AppleItem>();
        })

        this.addLocalTargetSensor<ClosestApple>((agent, references) => {
            return new TargetSensor(this.apples.closest(agent.transform.position));
        })
    }
}

Feature: Add possibility to configure actions better

Is your feature request related to a problem? Please describe.
Right now it's only possible to configure actions when generics are used. This method is useable for SO configs, as well as only useable as long as you have concrete implementations for the classes you pass along as generics.

Describe the solution you'd like
It should become possible to set config for an action, increasing the possibility to reuse actions and let them behave differently based on config.

Example

builder.AddAction<WanderAction>()
    .SetTarget<WanderTarget>()
    .AddEffect<IsWandering>(EffectType.Increase)
    .SetConfig(new WanderActionConfig {
        waitDuration = 10f
    });
public class WanderAction : ActionBase<WanderAction.Data>
{
    public override void Created()
    {
    }

    public override void Start(IMonoAgent agent, Data data)
    {
        data.Timer = this.config.waitDuration;
    }

    public override ActionRunState Perform(IMonoAgent agent, Data data, ActionContext context)
    {
        data.Timer -= context.DeltaTime;
        
        if (data.Timer > 0)
            return ActionRunState.Continue;
        
        return ActionRunState.Stop;
    }

    public override void End(IMonoAgent agent, Data data)
    {
    }

    public class Data : IActionData
    {
        public ITarget Target { get; set; }
        public float Timer { get; set; }
    }
}

New Feature: 'Freeform Debug Info' addition to 'Node Viewer'

As a consuming developer of the package, it would be helpful for me to display various data-points of debugging information and that I would like a good degree of control over which items these are and perhaps how they are formatted.

A possible approach to this, may be to register a delegated function - possibly from the same place where the consumer-developer is working with that data - but more likely either the brain, or some other centralised configuration centre.
Such a registration could work something along the lines of "here is reference to data point" + "here is the string template I want to use" ... "now go and generate the various messages async according to some scheduling handler" etc.

Note: The idea behind this issue originated in PR 38, where @crashkonijn has suggested that such an interface could possibly look like this:

public interface IAgentDebugger {
    public string GetInfo(IMonoAgent agent, IComponentReferences references);
}

Bug:

getting started tutorial results in error

followed tutorial on getting started - struggled as the "well doucmented" tutorial didnt mention which name spaces were needed, but finally got there. checked 5 times now, no steps missed, no errors on compile.

to reproduce new project import unity store asset, follow tutorial having to guess at name spaces

Expected behavior
my capsule to move

error
NullReferenceException: Object reference not set to an instance of an object
CrashKonijn.Goap.Behaviours.AgentBehaviour.SetGoal[TGoal] (System.Boolean endAction) (at Assets/CrashKonijn/GOAP/Runtime/CrashKonijn.Goap/Behaviours/AgentBehaviour.cs:180)
AgentBrain.Start () (at Assets/AgentBrain.cs:24)

except the goal is very much created

problem solved by changing from Start to Awake in GoapSetBinder, the setgoap had not been called. Suggest more checks required

Unity Version
2022.3

Unity.Collections Version
Please mention the Unity.Collections version you are using.

Package Version
Please mention the package version you are using.

Additional context
Add any other context about the problem here.

Example doesn't work

I tried the included example in an attempt to understand what this does, but the example seems incomplete somehow. When I press play nothing happens, the "throwable" is disabled and nothing seems to reference it to enable it, as well the "GOAP Visualizer" is blank when opened, as if there's been no logic implemented. https://i.imgur.com/o0Tpnp2.png

I'm very interested to see if this will be a viable AI system for a game I'm working on, but the lack of a working example makes that rather difficult.

Feature: Disable actions (through code)

Is your feature request related to a problem? Please describe.
When traversing the action graph to find a valid action to perform the resolver doesn't perform a 'full tree search' to see if ALL conditions could be met. Right now the system will just find any action that it can perform towards a goal, for any condition that isn't met in the tree.

There can be cases where a condition could be present in the world state, but where there's no action that could influence that particular world state.

Lets say you spawn an enemy with a random weapon which they cannot change. The ShootBowAction is not something that you'd like it to consider. You'd also not want it to PickupArrows. Adding a way to disable this action conditionally would solve this problem.

Describe the solution you'd like
I propose introducing a public void IsEnabled(agent, references) to an Action. By default it should return true.

Feature: Improve documentation

Is your feature request related to a problem? Please describe.
The documentation should be improved to explain concepts more clearly.

Describe the solution you'd like
A lot of documentation is pretty 'bare bone'. I've already done some tests to improve documentation using ChatGPT to fill in the blank.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.