Which AI Behavior Framework Should You Use? | AI Series 46

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 มิ.ย. 2024
  • Go to this video's Sponsor: snhu.edu/llamacademy and to see what the current average annual salary for a game developer programmer is and learn how you can get started!
    Learn about popular approaches to implement AI behaviors in your game and see which one is right for your use case! Using a Ferrari isn't the right answer for every problem. You'll learn about Unstructured AI, State Machines, Behavior Trees, and GOAP (Goal-Oriented Action Planning), the pros and cons of each one, and in which use cases they're most suitable for.
    What's next?
    ▶ Introduction to GOAP: • Introduction to GOAP |...
    ▶ GOAP Enemy AI Full Implementation: • GOAP Enemy AI FULL IMP...
    ▶ Behavior Tree Enemy AI Full Implementation: • Enemy Behavior Tree AI...
    ▶ State Machine Enemy AI Full Implementation: • Enemy State Machine AI...
    💸 Ongoing sales 💸
    ⚫ The Dev Days of Summer on the Asset Store: assetstore.unity.com/?aid=110...
    ⚫ Check out the latest Humble Bundles www.humblebundle.com/software...
    ⚫ Publisher Sale! 50% OFF an entire publisher's Assets and one for FREE! Publisher changes weekly! assetstore.unity.com/publishe...
    ⚫ Save up to 50% on NEW Assets: assetstore.unity.com/?new_sal...
    👨‍💻 Since we're not writing any code in this one, no GitHub project.
    📚 Resources:
    ⚫ Animator Docs: docs.unity3d.com/Manual/class... | docs.unity3d.com/Manual/Anima...
    ⚫ UFSM - A free and open source Hierarchical Finite State Machine framework: github.com/Inspiaaa/UnityHFSM
    ⚫ Fluid Behavior Tree - a Free and Open Source Behavior Tree Framework: github.com/ashblue/fluid-beha...
    ⚫ Opsive Behavior Designer: assetstore.unity.com/packages...
    ⚫ AI Tree: assetstore.unity.com/packages...
    ⚫ Node Canvas: assetstore.unity.com/packages...
    ⚫ Free GOAP Framework: assetstore.unity.com/packages... | github.com/crashkonijn/GOAP
    ❤ Believe in LlamAcademy's mission and have received value from the videos? Become a Supporter:
    ⚫ Patreon: / llamacademy
    ⚫ TH-cam Member: / @llamacademy or click the Join button on any video
    ⚫ GitHub Sponsor: github.com/sponsors/llamacademy
    ----
    Most tutorials come from knowledge gained making survival.llama.software Llama Survival - a top-down zombie survival shooter for Android and iOS.
    I also have some Unity Assets: assetstore.unity.com/publishe...
    Some links may be affiliate links, which at no additional cost to you, gives me a small portion of the purchase.
    #unitytutorial #tutorialtuesday #gamedev #tutorial #unity #llamacademy #gamedevelopment
    Chapters:
    00:00 Introduction
    00:24 Unstructured AI
    04:34 Sponsor - Southern New Hampshire University
    06:06 State Machine
    08:53 Behavior Tree
    11:50 GOAP - Goal Oriented Action Planning
    16:30 Support LlamAcademy

ความคิดเห็น • 82

  • @CrashKonijn
    @CrashKonijn 10 หลายเดือนก่อน +12

    Thanks for mentioning my project! Means a lot ❤

    • @LlamAcademy
      @LlamAcademy  10 หลายเดือนก่อน +3

      Thanks for providing such an awesome tool for us in an open source format 🧡

  • @LlamAcademy
    @LlamAcademy  10 หลายเดือนก่อน +6

    Go to this video's Sponsor: snhu.edu/llamacademy to learn more about an accredited degree program in Game Design and Development! Special thanks to SNHU for sponsoring this video!
    In case you skipped the description, here you can find some free and paid solutions for State Machines, Behavior Trees, and GOAP!:
    ⚫ UFSM - A free and open source Hierarchical Finite State Machine framework: github.com/Inspiaaa/UnityHFSM
    ⚫ Fluid Behavior Tree - a Free and Open Source Behavior Tree Framework: github.com/ashblue/fluid-behavior-tree
    ⚫ Opsive Behavior Designer: assetstore.unity.com/packages/tools/visual-scripting/behavior-designer-behavior-trees-for-everyone-15277?aid=1101l9QvC
    ⚫ AI Tree: assetstore.unity.com/packages/tools/behavior-ai/ai-tree-229578?aid=1101l9QvC
    ⚫ Node Canvas: assetstore.unity.com/packages/tools/visual-scripting/nodecanvas-14914?aid=1101l9QvC
    ⚫ Free GOAP Framework: assetstore.unity.com/packages/tools/behavior-ai/goap-252687?aid=1101l9QvC | github.com/crashkonijn/GOAP
    Some of these links may be affiliate links, which at no additional cost to you, gives me a small portion of the purchase.

  • @brickch4pel
    @brickch4pel 10 หลายเดือนก่อน +3

    I can always count on your channel for learning something new or even just clarifying some general concepts, even after years of gamedev.

  • @Trinimp
    @Trinimp 4 หลายเดือนก่อน +16

    i find the goap cons funny, because when i started imaging ai for my game, its the first design i thought of, without ever hearing about it.

    • @LlamAcademy
      @LlamAcademy  4 หลายเดือนก่อน +3

      You are too powerful 💪 great first idea

  • @lukeloobey
    @lukeloobey 9 หลายเดือนก่อน +2

    This is a great video with a really good overview of the different AI behavior models. It has enough detail to be very informative on each topic but not so much to be overwhelming with info, love it.

  • @themerpheus
    @themerpheus 10 หลายเดือนก่อน +24

    AI Tree is pretty good, much close to unreals behavior trees. Behavior designer starts getting very cumbersome to work with after having a couple of deep branches. Also EQS is a really important point in that one, because without EQS, you need a lot of leg work on AI positioning.

    • @LlamAcademy
      @LlamAcademy  10 หลายเดือนก่อน +5

      Agreed. EQS is a really nice benefit for using AI Tree over some of the other mentioned behavior tree solutions!

    • @DELPRODBEATS
      @DELPRODBEATS 10 หลายเดือนก่อน

      внатуре

    • @madboss2713
      @madboss2713 10 หลายเดือนก่อน

      @@DELPRODBEATS really

    • @madboss2713
      @madboss2713 10 หลายเดือนก่อน

      @@DELPRODBEATS pls speak English, Dunduk

    • @Joshua-hb7cs
      @Joshua-hb7cs 5 หลายเดือนก่อน +1

      Whats EQS

  • @alec_almartson
    @alec_almartson 10 หลายเดือนก่อน +3

    Thank You for making this video 💯👍🏻.
    So far I've been using my own solution based on FSM with some additions to address some special use cases, but I want to expand those functionalities, so I really have to choose a more developed, existing solution.
    So I will rewatch your video in the future as I will have to choose an A.I. Framework for a Game with enemies and bosses functioning under a "more interesting" A.I. Behaviour.
    It's very good to be able to count on you as a teacher for these "cool things" related to Unity, Game Dev, A.I., etc 😄

  • @drewvananne1796
    @drewvananne1796 4 หลายเดือนก่อน +2

    Thanks for the nice video! As some other comments have mentioned, combining hierarchical state machines with behavior trees can be very powerful. I've done this with behavior trees as the base framework of the AI, and the state machines existing as "Selector" nodes in the tree. When the state machine node is ran, it runs the statemachine logic and selects the branch that corresponds to that state. If a single state's tree becomes too complex, it can be broken down into smaller substates each having their own behavior tree and a new statemachine node at the root of them.
    I suppose it all comes down to preference but I prefer to handle scripted decision making with heirarchical state machines as you can have short lists of all the conditions that cause state transitions in one spot for each state or substate. Whereas behavior trees can become quite unruly if you have a single large tree jumping around to different points in that tree. (You have to remember which parts of the tree jumps to which other parts and how those nodes decide to jump. Essentially, the transitions feel scattered across the entire tree which has driven me crazy in the past)
    So, I try to keep behavior trees smaller and more readable by keeping them as directed acyclic graphs. Basically, just a convenient way to form sequences of actions with a given flow, while HFSM handles the transitions.
    If the desired behavior needs to more complex or emergent behaviors are desired, I agree that other frameworks like Utility AI or some kind of planner like GOAP or HTN can be nice. Really just comes down to what kind of behaviors you want from the AI and weighing the pros and cons, but I often like using the most simple frameworks first, and only delving into the more advanced frameworks for the specific AI states that need to be more complex.

    • @LlamAcademy
      @LlamAcademy  3 หลายเดือนก่อน

      Great suggestion. I typically start with the most simple approach and move up in complexity only when required as well.

  • @brazenzebra9581
    @brazenzebra9581 10 หลายเดือนก่อน +8

    I prefer the goap like structure. I have pseudo coded a structure similar to a goap-like structure for my simulation games and I think those kinds of structures make the most sense for complex behaviors. I just didn't realize the structure had a name. lol. Now it will be easier to find how others have implemented it. Thanks for the exposure to all this info!

    • @SpencerYonce
      @SpencerYonce 6 หลายเดือนก่อน

      I’m the same man.

  • @panampace
    @panampace 6 หลายเดือนก่อน +2

    The vast majority of AI enemies can simply use a state machine if all they need to do is pathfind and attack. Behavior Trees & GOAP are more for cases where your AI unit needs to interact with other systems.

  • @lucasrybzinski
    @lucasrybzinski 10 หลายเดือนก่อน +1

    very good! Relevant content.

  • @3zzzTyle
    @3zzzTyle 4 หลายเดือนก่อน +1

    GOAP actually sounds like the most "natural" of the solutions, closer to how we make choices as opposed to having some kinda tree in the mind.

  • @travis391
    @travis391 10 หลายเดือนก่อน +1

    Wish I could give more, keep up the great work!

    • @LlamAcademy
      @LlamAcademy  10 หลายเดือนก่อน

      Wow! Thanks so much Travis! 🧡

  • @CharlieFleed
    @CharlieFleed 10 หลายเดือนก่อน +8

    I am using a combination of hierarchical state machines and behavior trees for my XCOM-style prototype. Basically I run a different tree in every state. I coded both (borrowing A LOT from existing literature), so no fancy UI, all in code, but still quite modular and I am very happy with the result. I recommend looking into this sinergy. Hierarchical SMs can really address a lot of the scalability problems of FSMs.

    • @LlamAcademy
      @LlamAcademy  10 หลายเดือนก่อน +2

      I agree HFSM helps a lot with scalability, but still I find it cumbersome to set up all of the transitions as is required for responsive AI decision making in a FSM/HFSM. It can be very effective. My preference for more complex leans towards BT/GOAP though because I find them easier to work with as the complexity increases.

    • @AdamFraserKruck
      @AdamFraserKruck หลายเดือนก่อน

      I agree. HSM and BT have different strengths. A mix of both like you have seems to work very well.

  • @Kudoshi
    @Kudoshi 10 หลายเดือนก่อน +1

    Great video. Have always been wondering about the different AI Behaviour Framework.
    Curious to know how other games does their AI

  • @obscure045
    @obscure045 10 หลายเดือนก่อน +8

    Very good explanation. Can you make a tutorial on G.O.A.P?

    • @LlamAcademy
      @LlamAcademy  10 หลายเดือนก่อน +2

      Thanks! I'm working on something with GOAP now 😉 stay tuned

    • @restart_gaming
      @restart_gaming 8 หลายเดือนก่อน

      @@LlamAcademy looking forward to it! :)

  • @pirateskeleton7828
    @pirateskeleton7828 7 วันที่ผ่านมา

    Behavior trees are still state machines, however it organizes the states by hierarchy and goes into sub-states. You can massively increase the scalability of a state machine by creating sub-states. There is no reason anyone would have to define every single transition condition between every state.

  • @GradoFun
    @GradoFun 10 หลายเดือนก่อน +4

    I would like to see some tutorials on trees or goap, in terms of some action or strategy game

    • @LlamAcademy
      @LlamAcademy  10 หลายเดือนก่อน

      Stay tuned 😉

  • @sinho113
    @sinho113 10 หลายเดือนก่อน

    i'm new to making games in unity
    right now i'm using a mix between scripts to checks for conditions and animator state machine to perform them.
    enemy ai always trigger my procrastinator within ;D
    now i'm gonna take a look at behaviour trees

  • @wicgamesdev
    @wicgamesdev 10 หลายเดือนก่อน

    I also like the Free Behaviour tree runner made by The kiwi coder, a mate developper on unity.
    got some bugs, but does the job, higly customizable.

  • @samuelbegue4756
    @samuelbegue4756 10 หลายเดือนก่อน +2

    if you want a video subject I think it could be interesting to do a series on the development of a hearthstone-style combat card system

    • @LlamAcademy
      @LlamAcademy  10 หลายเดือนก่อน +1

      Thanks!

  • @gendalfgray7889
    @gendalfgray7889 7 หลายเดือนก่อน +4

    I you look closely you will see that BT is state machine. Difference is transition rules fused with tasks and transitions go to next branch. That simplification of transitions sacrifice flexibility for better readability.

  • @Diablokiller999
    @Diablokiller999 10 หลายเดือนก่อน +1

    This is awesome, right before I want to start with enemies :)
    Btw. do you mind doing something like this for Player Controllers as well?
    I'm currently struggling combining my movement, camera and weapon scripts, which are based off of (hierarchical) state machines and how they communicate with another.
    Like how my movement influences the camera and if I should be able to shoot while sliding.
    Still can't find a good solution and am now working with observer based patterns to send signals between those objects.

    • @robertwaremusic
      @robertwaremusic 6 หลายเดือนก่อน

      I second this, same problems

  • @quentinquadrat9389
    @quentinquadrat9389 9 หลายเดือนก่อน +1

    Nice video! I did not know about GOAP. Your video is missing talking about of logical / planning languages such Prolog and PDDL to have a full analysis :)

    • @LlamAcademy
      @LlamAcademy  9 หลายเดือนก่อน

      Thanks! Maybe PDDL deserves its own full video 🤔

    • @quentinquadrat9389
      @quentinquadrat9389 9 หลายเดือนก่อน

      @@LlamAcademy yes PDDL is not very known

  • @cynth4941
    @cynth4941 10 หลายเดือนก่อน

    Behaviour Designer (asset shown on video) is on sale right now btw.

  • @charlotte80389
    @charlotte80389 10 หลายเดือนก่อน +1

    underrated af

  • @jeffreyhersh908
    @jeffreyhersh908 10 หลายเดือนก่อน +5

    Great video. Any thoughts on Utility AI or a GOAP/Utility hybrid?

    • @GiantsOnTheHorizon
      @GiantsOnTheHorizon 10 หลายเดือนก่อน +2

      I’ve been using the WiseFeline Utility AI. I haven’t combined it with GOAP but, I really like it’s flexibility.

    • @LlamAcademy
      @LlamAcademy  10 หลายเดือนก่อน +2

      I didn’t dive into Utility AI yet, but with my super basic understanding it sounds like that’s the ultimate combination for advanced AI like RTS “main” AI. I was thinking about the RTS AI a lot for this video. I cut out all my discussion on it because I thought it needed more investigation before I talked a lot about it.
      Even with GOAP I was struggling to see how the RTS AI would be able to multitask effectively outside of throwing several options against the GOAP system and picking the “best” one. From what I understand this is a function Utility AI can handle more effectively when combined with GOAP.

    • @GiantsOnTheHorizon
      @GiantsOnTheHorizon 10 หลายเดือนก่อน +2

      @@LlamAcademy I'm not familiar enough with GOAP to know how it interacts with with Utility AI. Maybe with the priority system but, Utility AI seems to use that too. I've spent a week or so learning and documenting WiseFeline which I really like. If you ever want to do a video on the topic and want an easier path to get started, I'd be happy to share my notes and answer any questions.
      By the way, what I like about Utility AI is that you basically have Actions, Considerations, and Targets as your main concepts. There are typically multiple Considerations on each Action which get added together. Based on the resulting value, it is determined what Action should be taken. While an Action doesn't always have to go to a "Target' that is often what the Action does. So... you have a pretty simple structure which just keeps scoring itself. As things change on your screen, the scores will continue to determine what the proper action is and what target to go to or what thing to do.
      Hope this helps.

    • @jeffreyhersh908
      @jeffreyhersh908 10 หลายเดือนก่อน

      @@LlamAcademy Yeah GOAP doesn't seem like a good fit with an RTS. However, Utility is one since you don't need to run the A* algorithm for each decision. The dark art with Utility AI is the costing function to determine your considerations and actions.
      FYI, there is a newer form of GOAP that organizes collections of actions into tasks. So it saves some processing by fitting together these collections of actions to meet the goal. I unfortunately do not remember what is it called off the top of my head but it was used in the Transformer: Cybertron games from a few years ago.

    • @TChrisBaker
      @TChrisBaker 10 หลายเดือนก่อน

      I have been learning about Utility AI. This video series gave me a good start th-cam.com/play/PLDpv2FF85TOp2KpIGcrxXY1POzfYLGWIb.html

  • @PixelBlight
    @PixelBlight 10 หลายเดือนก่อน +1

    Don't underestimate the "Any" state as it can make your spiderweb look more like a tree, and avoid n² 😅

  • @Hazzel31337
    @Hazzel31337 5 หลายเดือนก่อน

    nice overview

    • @LlamAcademy
      @LlamAcademy  4 หลายเดือนก่อน

      Thanks 😊!

  • @eryberto87
    @eryberto87 7 หลายเดือนก่อน +1

    What about utility AI?

  • @SuliXbr
    @SuliXbr 3 หลายเดือนก่อน

    I don't see how goap is different from behavior tree, it just depends how you set up the order of priorities in the behavior tree

  • @johnblake5114
    @johnblake5114 8 หลายเดือนก่อน +1

    Which one does GTA or Elden ring use? Anyone know?

  • @pavanvenkat9182
    @pavanvenkat9182 8 หลายเดือนก่อน

    what do you think will be a good framework for a game like domino ?

    • @LlamAcademy
      @LlamAcademy  8 หลายเดือนก่อน

      Dominos like the tabletop game with the little white pieces and black dots? I'm not an expert at this game but I think it's relatively simple based on what you have available and the available moves. With my current knowledge of that game I'd honestly probably start with Unstructured AI because I think it's very simple. You have it analyze your "hand" and the board and pick the "best" or a random available move. Even to add difficulty you could just weight the available moves on how good they are and have different difficulty levels prefer better/worse moves.

    • @pavanvenkat9182
      @pavanvenkat9182 8 หลายเดือนก่อน

      @@LlamAcademy , got it thanks!

  • @syntax_error6882
    @syntax_error6882 10 หลายเดือนก่อน +2

    fluid behavior tree and its free ;-)

    • @LlamAcademy
      @LlamAcademy  10 หลายเดือนก่อน +1

      Thanks! I'll add that as a reference in the description!

    • @edward3190
      @edward3190 2 หลายเดือนก่อน

      thanks!

  • @therebelliousgeek4506
    @therebelliousgeek4506 10 หลายเดือนก่อน

    Behaviour Designer tutorial series please?

    • @LlamAcademy
      @LlamAcademy  10 หลายเดือนก่อน +1

      Something with designing Behavior Trees is in the works 😉

    • @therebelliousgeek4506
      @therebelliousgeek4506 10 หลายเดือนก่อน

      You're a savior Liam@@LlamAcademy

  • @brutalgamer1507
    @brutalgamer1507 10 หลายเดือนก่อน +1

    sir how can we create advanced AI like souls game like sekiro dark soul please please

    • @LlamAcademy
      @LlamAcademy  10 หลายเดือนก่อน +1

      I haven’t played that so not sure 🤔

    • @brutalgamer1507
      @brutalgamer1507 10 หลายเดือนก่อน

      @@LlamAcademy no need to play just watch sekiro enemy ai video that enough

    • @brutalgamer1507
      @brutalgamer1507 10 หลายเดือนก่อน

      @@LlamAcademy sir tell me how can i create enemy strafing bheavior when player is also strafing. I mean just watch sekiro vs isshin boss fight on yt you will get qn idea what i am talking about

  • @donaldwheeler5989
    @donaldwheeler5989 4 หลายเดือนก่อน

    How about HTN?

  • @treymtz
    @treymtz 5 หลายเดือนก่อน +1

    Would GOAP be the same as Utility AI?

    • @LlamAcademy
      @LlamAcademy  5 หลายเดือนก่อน +1

      Great question! GOAP and Utility AI are different. DukeZhou on Stack Exchange does a pretty good writeup of how they are different: ai.stackexchange.com/questions/8651/what-is-the-difference-between-goal-based-and-utility-based-agents

  • @zendraw3468
    @zendraw3468 10 หลายเดือนก่อน

    a bit overkill on the red paint there.

    • @LlamAcademy
      @LlamAcademy  10 หลายเดือนก่อน +3

      Yeah....I got it done the day before I recorded this so it was still on my scalp 😅

  • @manofapocalypse
    @manofapocalypse 6 หลายเดือนก่อน

    7:36 thats why i call animations from code

  • @Happy-go-luckyTV
    @Happy-go-luckyTV 10 หลายเดือนก่อน

    I feel like goal oriented is simply an abstraction of AI.

  • @svenrawandreloaded
    @svenrawandreloaded 4 หลายเดือนก่อน

    4:35 don't waste your time at school, ESPECIALLY with something like game dev. It's incredibly expensive and most industry jobs ARE NOT worth it and are probably NOT prevalent in your area. Besides, the only way you will ever learn something is if you have enough interest in it to the point where you can teach yourself.

  • @rjmichalski7172
    @rjmichalski7172 6 หลายเดือนก่อน

    A blend tree would fix the animator mess