[Released] Opensource GOAP for AI v2.1.19

GitHub * Asset Store * Documentation * Discord

Hello!

I re-build the GOAP I build for my graduation project 6 years ago. After months of working in my spare time I can finally call it v2! Have a look on GitHub!

What is GOAP?
GOAP stands for Goal Oriented Action Planner. It is an AI architecture that simplifies the process of building complex Finite State Machines (FSMs) by allowing you to define goals and actions, and automatically figuring out which actions to take to achieve those goals. Most famous of powering the AI used in F.E.A.R.

How can it help you?
GOAP can help you building complex AI by defining simple actions which GOAP connects together. It also resolves the best action to take based on the game state. This should make managing a complex decision graph much easier!

Core features

  • The resolver is multithreaded (using jobs).
  • GOAP visualizer window.
  • Setup using two methods: ScriptableObject configuration in the editor, or by using code.
  • Two example scenes using both setup methods.
  • Support for data injection using your favorite IoC.
  • The core is unit tested.
  • Well documented.
  • Video tutorials

Future

  • I’m working on adding various improvements, mostly improving the creation workflows using the editor!

I’m very eager to learn what you think of this project, let me know if you have any questions!

6 Likes

I’ve been very busy the last week. A couple of people joined the discord and their feedback has been amazing!

The following changes where made:

Version 2.0.1

  • Added GOAP set config validators. These will notify you of the most common configuration errors and warning! :sparkles:

Version 2.0.2

  • Fixed bug where cost wasn’t included in the resolver
  • Fixed sensor validators not showing meaningful name in the error
  • Goap Set Validator errors now include the name of the set
  • Added tests for GoapSetJobRunner
  • Added notes about this project using Unity 2022.2
  • Added simple tests that load both demo scenes and validates that they run

Version 2.0.3

  • Improved node viewer, now includes cost.
  • Fixed a bug displaying generic types in node viewer
  • Complex example now shows what the agent is doing by using the same UI as the simple demo

Version 2.0.4

  • Added FAQ page in docs
  • Added lifecycle page to docs
  • Added agent move mode (Agents can now also perform actions while moving)
  • Various minor adjustments

Version 2.0.5

  • Fixed bug in multiple validators
  • Added tests for these bugs
  • Feature: Actions can now handle not having a target, it will use the transform of the agent as the target.

Version 2.0.6

  • Added Zenject example
  • Added GetInRange method to action interface
  • Fixed bug with agent being destroyed but still processed by the resolver

I’ve also submitted the project to the Unity Asset Store!

The past month has been very busy! A couple people joined the discord and it’s nice to see the project getting integrated, as well as people helping each other!

These are the latest changes:

Version 2.0.7

  • Fixed: IGoapSet containing implementation reference instead of interface

Version 2.0.8

  • Added GetComponentInChildren to Agent references

Version 2.0.9

  • Added OnGoalCompleted event

Version 2.0.10

  • Fixed collections > 2.1 breaking this package due to NativeMultiHashMap being renamed to NativeParallelMultiHashMap

Version 2.1.0

  • Added Unity 2021 support (tested with 2021.3)
  • Added GoapRunnerEditor
  • Improved performance of NodeViewer
  • Added states to AgentEditor

:warning: Breaking changes :warning:

Upgrade docs can be found here: Upgrading | GOAP

Also:
Added package to open upm: Unity GOAP | com.crashkonijn.goap | Unity Package (UPM) | OpenUPM
Added package to itch.io: Goal Oriented Action Planner for Unity by CrashKonijn

The past weeks there’s been a couple updates, including three new contributors!

Version 2.1.1

  • Fixed: Issue where agent would deadlock in the complex example.

Version 2.1.2

  • IDataReferenceInjector.GetComponent becomes GetCachedComponent to better communicate purpose. For backward compatibility, previous versions retained but marked as obsolete.

Version 2.1.3

  • Major name refactor to change all derivatives of ‘Set’ to ‘GoapSet’. This should communicate it’s purpose more clearly.

Version 2.1.4

  • Added GetGoals() to the IGoapSet.

Version 2.1.5

  • Removed empty readme files that were generating warnings/errors
  • Fixed incorrect variable name
  • Fixed planned planning action for satisfied condition
  • Fix/various warnings
  • Fix: NodeViewer breaking

Today the package got approved to the Unity Asset Store!

Version 2.1.6

1 Like

Another couple of updates have been done!

Version 2.1.7

Version 2.1.8

Cool project, i’m always amazed at people that is able to not only complete versions but to also keep updating them.

1 Like

Thank you for your kind words! For v2 I put a lot of time and effort in ‘marketing’ it and building a community. The project is gaining traction and staying in contact with actual users of the project helps a lot in staying motivated in the long term!

Some feedback:

  1. On https://goap.crashkonijn.com/introduction/gettingstarted WanderTargetSensor.cs seems to be missing using UnityEngine;
    as it’s using Vector3 and other Unity stuff.

  2. For retards like me (i don’t even fully know GOAP, just knew it was a way to solve complex/scale multiple behaviours) it would be quite useful to see a diagram previewing the classes/concepts involved in adding one action at the getting started page. One like https://3254548975-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZpAsOUBq8CwXUNyR25c4%2Fuploads%2Fgit-blob-6900835c68b4eb8b2108c75e2b0e4266db311f00%2Ffaq_target_without_move_action.png?alt=media

  3. Does choosing between ScriptableObjects and Code have any impact? On performance or something?

  4. Very stupid question: How can the resolver be multithread if it’s accessing things like the agent’s transform/Monobehaviours? I thought Unity Jobs cried quite a lot because of things like that.

1 Like

Great catch! I’ll add that!

Wonderful idea, I’ll add that to my todo list!

It shouldn’t, both of these methods are ‘compiled’ into (the same) data that the resolver needs.

You’re right, you can’t access this information from within a job. During the update loop all required information is gathered from the main thread and transformed to information that works for the job system before triggering the job.

This is done in the GoapSetJobRunner, specifically in the Run and FillBuilders methods.

1 Like

@w34edrtfg This is an overview of the FixHungerGoal, it’s not the WanderGoal that’s used in the getting started but is much more complete (and available in the ‘Simple Demo’). Is this what you had in mind?

Yess

@CrashKonijn another stupid question: Somewhere you’re getting the list of active agents (so you can iterate them). Do i have a method to get said list or i have to build it myself?
(I want to get the agents to look for targets)

Another small detail, i get a deprecation warning for the example in the docs at https://goap.crashkonijn.com/introduction/gettingstarted/code:

GoapSetBinder.cs(10,25): warning CS0618: 'GoapRunnerBehaviour.GetSet(string)' is obsolete
1 Like

Hi!

I think I completely read over your question! It is possible to get all the agents that are present, but I don’t recommend relying on the GOAP to provide you this information. Making something of your own would indeed be better.

Thanks, I’ve updated that in the docs! The diagram is now in the getting started as well :smile:

It’s been a while since I was able to do an update (moving houses is a lot of work apparently), but here’s a new version based on community feedback:

Released Version 2.1.9

  • Added possibility to add an IGoapSetConfig to the GoapRunnerBehaviour
  • Added effect type (Increase/Decrease) instead of increase bool
  • Added warning in the editor when no stylesheets could be loaded (project files have been moved to another location)
  • Fixed: Node viewer not being draggable in 2021.x

by @CrashKonijn in Various improvements by crashkonijn · Pull Request #69 · crashkonijn/GOAP · GitHub

Released Version 2.1.10

Released Version 2.1.11

I also submitted this version to unity

I started testing this and so far I like how it is made.
I think you can add something that will help others. instead of relying on Time.deltaTime, add the option to override that with custom deltaTime.
thanks!

Thanks for you kinds words!

I’m not a 100% sure what you’re referring to. Are you talking about the planner running on Update?

Released Version 2.1.12

Released Version 2.1.13

  • feat: added update-package workflow
  • Added docs about world state
  • Create release-drafter.yml config
  • chore: Added release-drafter

Release version 2.1.14

  • feat: added samples to the package! They can now be imported using the package manager in Unity!

Released version 2.1.15!

  • Feature: Improved editor readability (especially in light mode)
  • Fix: Goal completion not clearing goal
  • Improved readme and package.json text
  • docs: Update GettingStarted.md with missing using (by @ )

Could you add a tutorial video that shows the documentation and explains it step by step.
The explanations would be nice if you do it with multiple small examples inside unity.

This will be a fun way to uncover the whole framework and will answer all our questions and lets us discover all its capabilities.