Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[Released] Opensource GOAP for AI v2.0.0

Discussion in 'Assets and Asset Store' started by CrashKonijn, Apr 14, 2023.

  1. CrashKonijn

    CrashKonijn

    Joined:
    Mar 4, 2010
    Posts:
    239

    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.
    Future
    • I'm hoping to build a community around this project. If you're interested you can join the discord server where I'm happy to answer all question!
    • Next step would be to publish this project on the Unity Asset Store.
    • I'm going to use this project in my own game, so expect more improvements in the future!
    I'm very eager to learn what you think of this project, let me know if you have any questions!

    explanation_config.png explanation_multithreaded.png explanation_examples.png explanation_github.png

     
    Last edited: Jun 8, 2023
    PolyCrusher, Onigiri and giraffe1 like this.
  2. CrashKonijn

    CrashKonijn

    Joined:
    Mar 4, 2010
    Posts:
    239
    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! ✨
    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!
     
  3. CrashKonijn

    CrashKonijn

    Joined:
    Mar 4, 2010
    Posts:
    239
    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
    ⚠️ Breaking changes ⚠️
    Upgrade docs can be found here: https://goap.crashkonijn.com/introduction/upgrading

    Also:
    Added package to open upm: https://openupm.com/packages/com.crashkonijn.goap/
    Added package to itch.io: https://crashkonijn.itch.io/goap
     
  4. CrashKonijn

    CrashKonijn

    Joined:
    Mar 4, 2010
    Posts:
    239
    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
     
  5. CrashKonijn

    CrashKonijn

    Joined:
    Mar 4, 2010
    Posts:
    239
    Today the package got approved to the Unity Asset Store!

    Version 2.1.6
     
    JamesVZA likes this.
  6. CrashKonijn

    CrashKonijn

    Joined:
    Mar 4, 2010
    Posts:
    239
    Another couple of updates have been done!

    Version 2.1.7
    Version 2.1.8
     
  7. w34edrtfg

    w34edrtfg

    Joined:
    Nov 23, 2014
    Posts:
    72
    Cool project, i'm always amazed at people that is able to not only complete versions but to also keep updating them.
     
    CrashKonijn likes this.
  8. CrashKonijn

    CrashKonijn

    Joined:
    Mar 4, 2010
    Posts:
    239
    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!
     
  9. w34edrtfg

    w34edrtfg

    Joined:
    Nov 23, 2014
    Posts:
    72
    Some feedback:
    1. On https://goap.crashkonijn.com/introduction/gettingstarted WanderTargetSensor.cs seems to be missing
    Code (CSharp):
    1. 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.../faq_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.
     
    CrashKonijn likes this.
  10. CrashKonijn

    CrashKonijn

    Joined:
    Mar 4, 2010
    Posts:
    239
    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.
     
    w34edrtfg likes this.
  11. CrashKonijn

    CrashKonijn

    Joined:
    Mar 4, 2010
    Posts:
    239
    @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?

    upload_2023-7-20_9-16-39.png
     
  12. w34edrtfg

    w34edrtfg

    Joined:
    Nov 23, 2014
    Posts:
    72
    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:
    Code (csharp):
    1.  
    2. GoapSetBinder.cs(10,25): warning CS0618: 'GoapRunnerBehaviour.GetSet(string)' is obsolete
    3.  
     
    Last edited: Jul 21, 2023
    CrashKonijn likes this.
  13. CrashKonijn

    CrashKonijn

    Joined:
    Mar 4, 2010
    Posts:
    239
    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 :D
     
  14. CrashKonijn

    CrashKonijn

    Joined:
    Mar 4, 2010
    Posts:
    239
    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 https://github.com/crashkonijn/GOAP/pull/69