Behaviour Trees: The Cornerstone of Modern Game AI | AI 101

Ойындар

As the new series of AI 101 continues I take a look at behaviour trees - arguably the dominant AI technique in AAA games - and tell you how they work.
If you're interested in learning more about behaviour trees here are some links to some resources you might find useful:
Chris Simpson: "Behaviour Trees for AI - How They Work"
www.gamasutra.com/blogs/ChrisS...
Alex Champandard: "Understanding Behaviour Trees"
aigamedev.com/open/article/bt-...
Epic Games: "Behaviour Tree (Unreal Engine 4 Documentation)"
docs.unrealengine.com/en-us/E...
--
AI and Games is series on research and applications of Artifical Intelligence in video games. It's is supported through and wouldn't be possible wthout the wonderful people who support it on Patreon.
/ ai_and_games
www.paypal.me/AIandGames
www.ko-fi.com/AIandGames
Get yourself an AI and Games t-shirt over on Teespring!
teespring.com/stores/aiandgames
You can follow AI and Games (and me) on Facebook, Twitter and Instagram:
/ aiandgames
/ aiandgames
/ aiandgames
/ get_tuda_choppa
--
Games in this episode (in order of appearance):
Halo 2
Far Cry Primal
Tom Clancy's The Division
Halo 3
Spec Ops: The Line
Ghost Recon: Wildlands
Batman: Arkham Asylum
F.E.A.R.
DOOM
BioShock: Infinite
Alien: Isolation
--
Soundtrack for this episode is "Twilight Metropolis A" and "This is My City" by TeknoAxe under the terms of a Creative Commons 4.0 license.
/ teknoaxe
/ teknoaxe
#gamedev #ArtificialIntelligence #BehaviourTrees

Пікірлер: 121

  • @AIandGames
    @AIandGames5 жыл бұрын

    AI 101 is back for 2019 with a new episode dedicated to Behaviour Trees: one of the most commonly adopted AI technologies in modern video game development. Long-term viewers of the show will have noticed how frequently Behaviour Trees have appeared - with them cropping up in Spec Ops: The Line, Far Cry, Halo and The Division last year alone. So let's take a moment to explain how they work and why developers and designers like to use them.

  • @fireaza
    @fireaza5 жыл бұрын

    "Where it decides which child to execute based on some logic in the world" Man, this video got *dark* .

  • @CCGS

    @CCGS

    5 жыл бұрын

    Sophie's choice in here all of a sudden...

  • @illusions500

    @illusions500

    5 жыл бұрын

    "sequence nodes allow us to execute children one after another"

  • @fatal_pastry1176

    @fatal_pastry1176

    5 жыл бұрын

    Reminds me of my OS course, where we talked about zombie and orphan children and how/when to kill them. Ahh, CS. . .

  • @knownas2017

    @knownas2017

    5 жыл бұрын

    Execute. Them. All.

  • @Gnurklesquimp

    @Gnurklesquimp

    4 жыл бұрын

    FOR THE BEHAVIOUR TREE!

  • @JTaylor2K
    @JTaylor2K3 жыл бұрын

    All my brain picks up in this is “child execution” and “ child manipulation “

  • @DirkArnez

    @DirkArnez

    Жыл бұрын

    Hahahahahahahahaha there really are a lot of scary vocabulary in our tech world hahahahahahahahaha

  • @tjrizvi251

    @tjrizvi251

    2 ай бұрын

    ....man...

  • @nathanaelgazzard7989
    @nathanaelgazzard79894 жыл бұрын

    As an aspiring game developer, there are moments when I feel particularly excited and motivated to make games. For example, every time I listen to the silent hill 2 soundtrack. In this instance, it's new insights and knowledge from you that is driving that inspiration. Thanks Tommy😊

  • @JanB1605
    @JanB16055 жыл бұрын

    We use something similar in automation technologies to program the behaviour of machines. We have a special programming language for this, called "SFC" or "Sequential Function Chart".

  • @shayoko6
    @shayoko65 жыл бұрын

    AIs are quite fascinating. without them we wouldn't have video games. i'm grateful for all the talented people through the years which have been responsible for creating such wonderful things.

  • @mftripz8445

    @mftripz8445

    4 жыл бұрын

    Not only are you a weeb but you are a rardo

  • @DasAntiNaziBroetchen

    @DasAntiNaziBroetchen

    3 жыл бұрын

    @@mftripz8445 Wtf is a rardo?

  • @DasAntiNaziBroetchen

    @DasAntiNaziBroetchen

    3 жыл бұрын

    @Awawawa CM Ok. Wtf is a rardo?

  • @Crimbtw

    @Crimbtw

    2 жыл бұрын

    @Awawawa CM Im here to post a comment a year later... I shall await for another comment In a year

  • @Crimbtw

    @Crimbtw

    2 жыл бұрын

    @Awawawa CM you too :)

  • @Deadener
    @Deadener3 жыл бұрын

    I already know how BTs worked, but it's great to hear some of the reasons why you might use them over the alternatives. Your explanations are also fantastic, and I wish this video had been around when I was first learning them.

  • @squanguslobotomus7890
    @squanguslobotomus78903 жыл бұрын

    I would love to see games add outside forces that are like stats but instead of changing power, it would change how they approach scenarios. Let's say one enemy has high self preservation, but low bravery. They would usually stay under cover and run away when you get close. Or what about high bravery and low self preservation. This ai would rush you at low health and usually leave cover alot. This allows for a much more random experience with ai, but still somewhat predictable due to different enemy types keeping traits close to their purpose, like defense always having higher bravery but high self preservation, meaning they will stay under cover but sometimes move away from it. Obviously there would be more factors but this is just a basic idea.

  • @iw_legendary_sayain2215
    @iw_legendary_sayain22155 жыл бұрын

    @ 1:19 the background marine says “They killed the Chief! You bastards!” That’s gotta be a south park reference.

  • @mftripz8445

    @mftripz8445

    4 жыл бұрын

    ? I don't remember no line said like that from sp

  • @skyacaniadev2229

    @skyacaniadev2229

    4 жыл бұрын

    You mean chef?

  • @Gnurklesquimp

    @Gnurklesquimp

    4 жыл бұрын

    For people wondering, this is in reference to the iconic ''They killed Kenny'' line

  • @pierreo33

    @pierreo33

    4 жыл бұрын

    @@Gnurklesquimp Thanks cpt obvious

  • @Gnurklesquimp

    @Gnurklesquimp

    4 жыл бұрын

    @@pierreo33 You realize people were asking? Or do you not understand how captain obvious works? Reminds me of how people use r/woosh, it isn't that complicated

  • @zoecarlibur
    @zoecarlibur5 жыл бұрын

    When this popped up on my feed and I saw the date. I was so happy for a new video!

  • @AIandGames

    @AIandGames

    5 жыл бұрын

    Still gotta case study lined up for this month too. Currently there's at least two videos a month until April. Provided I get them finished! 😅

  • @MichaelJackson1479
    @MichaelJackson14795 жыл бұрын

    This is monumental work, thank you for crafting these videos with so much care. The only issue in my opinion was in the comparison between the methods, you gave behaviour trees and FSMs so much attention but almost forgot GOAP :c

  • @AIandGames

    @AIandGames

    5 жыл бұрын

    Thanks for watching. GOAP will be getting it's own episode at some point, alongside other planning approaches. Plenty more to cover to keep me busy.

  • @blehblehson1194
    @blehblehson11945 жыл бұрын

    Oh good thanks! I am glad you made this video.

  • @NecroteckLabs
    @NecroteckLabs3 жыл бұрын

    Thank God for this channel and THIS video. Thank you mate, helped me loads. I'm working on an immersive sim and wasn't sure which technique to use.

  • @sam_making_games
    @sam_making_games3 жыл бұрын

    I was looking for best practices for using Behavior trees but this is fun to watch too.

  • @GameDevNerd
    @GameDevNerd2 жыл бұрын

    Great overview of behavior trees. I may be taking a job working on complex behavior trees and I'm studying everything I can about it. Appreciate the video!

  • @ObiAdeGaming
    @ObiAdeGaming5 жыл бұрын

    Love your vids dude, came for the division, stayed for the informative AI explanations 👍👍

  • @AIandGames

    @AIandGames

    5 жыл бұрын

    Heh heh, stick about. I have some good stuff lined up between now and March.

  • @DanielKarbach
    @DanielKarbach3 жыл бұрын

    "Decide which child to execute" hmmm, trolley problem in AI?

  • @apresmidi153
    @apresmidi1537 ай бұрын

    Great video and concise explanation of how I can use a data structure I already know to create scalable AI. Bravo!

  • @user-ns1nn6nl3j
    @user-ns1nn6nl3j3 ай бұрын

    my favorite new channel!

  • @mek101whatif7
    @mek101whatif7 Жыл бұрын

    > A finate state machine needs to be updated at every tick. If you know witch external states a FSM observes, you can just hook it up to those states changing as events and evaluate an internal state change only when any of those external events fire

  • @perkkie
    @perkkie5 жыл бұрын

    You have way too low sub count. This channel needs more spotlight. Great job mate.

  • @AthenaMarriesDionysus
    @AthenaMarriesDionysus5 жыл бұрын

    He held my lecture today!

  • @pricelessair
    @pricelessair3 жыл бұрын

    Happy find!👍

  • @andycarr3711
    @andycarr37116 ай бұрын

    I'm only a hobbyist developer but I'd suggest it doesn't entirely replace the object's state machine but allows it to run a very simple one, state.move, state.reload etc.

  • @blorp-
    @blorp-5 жыл бұрын

    Super helpful video. Thanks!!

  • @yukikun9685
    @yukikun96854 жыл бұрын

    best thing ever. thank you for this!

  • @BaseRealityVR
    @BaseRealityVR4 жыл бұрын

    Excellent Video

  • @PopulationOfAfrica
    @PopulationOfAfrica5 жыл бұрын

    You should look into Utility AI for a future video, I haven't seen it mentioned here but from my own work it looks to be an incredibly powerful and scalable solution.

  • @AIandGames

    @AIandGames

    5 жыл бұрын

    Definetely on my to-do list (somewhere).

  • @PopulationOfAfrica

    @PopulationOfAfrica

    5 жыл бұрын

    @@AIandGames Awesome and great content, I love what you're doing.

  • @JohnVanderbeck

    @JohnVanderbeck

    5 жыл бұрын

    @@AIandGames I too would love to see a video on utility systems.

  • @sergiuferentz9125
    @sergiuferentz91252 жыл бұрын

    I was listening to this on 0.75x for some reason. Thought Tommy had one too many pints down at the pub before filming this video. Great content regardless of level of sobriety !

  • @AIandGames

    @AIandGames

    2 жыл бұрын

    Just listened to it myself and yeah... sounds like I've had a little too much to drink. 😂

  • @SkyYurt
    @SkyYurt5 жыл бұрын

    I'm currently developing an Tank AI using Behaviour Trees. I have found it to be very challenging to debug my AI as I work on it. My solution was to make a simple Debug leaf node, that would output custom text whenever the behaviour tree hit that point of the tree. What other techniques do you use to debug your behaviour trees?

  • @AaditDoshi

    @AaditDoshi

    5 жыл бұрын

    It really depends on what system ur using. Unreals behavior trees let u put break points on the nodes. U could display the behavior trees current chain of running nodes above the AI.

  • @SkyYurt

    @SkyYurt

    5 жыл бұрын

    ​@@AaditDoshi I'm using Unity as the game engine and writing the behaviour tree from scratch using C#, so I was looking for more of an idea of a solution, which I then could implement. Displaying the current chain of nodes sounds like an good idea. I imagine I could have each node return both their status and their identifier and then make the root node output the chain of identifiers to the user.

  • @Ye4rZero
    @Ye4rZero5 жыл бұрын

    What an awesome unique channel! +1 sub

  • @jassem3441
    @jassem34412 ай бұрын

    Thank you !

  • @saturn7_dev
    @saturn7_dev Жыл бұрын

    Yeah , good video. I'm currently using finite state machine to make an enemy AI. The Blackboard you mentioned for me is really just global variables used by any and all enemies that's updated once from the players Behavior. Some good points though as yes, had a bit of mass jungle of things needing to code for when sharing functions and code across states....I can see why they use trees. I tend to use 2 states - the main state and its sub state (bit like tree structure) to keep track of what to update when else there is a lot of conflicts and difficult debugging issues...

  • @LeonardoRamos01
    @LeonardoRamos013 жыл бұрын

    Hi! Great video! I really like your content 👍🏽. I got a little confused with the Reusability part, couldn't it be that Finite State Machines reuse more general states? Why is it just available for Behavior Trees?

  • @fareastarmadildo5093
    @fareastarmadildo50935 жыл бұрын

    Since using Behavior Trees depends on the type of game and its scale, what is recommended to use in a simple tactical rpg? I have made a finite state machine but I think it's lacking and the code will get really complicated if I get into this, so are behaviour trees more appropriate?

  • @bezerker2173
    @bezerker21733 жыл бұрын

    So question, im trying to make a game, and im not new to coding but very very new to game design. Im trying to make an old school final fantasy style rpg, with 2d sprites and turn based combat. My question is, are behavior trees a good idea for the enemies in combat? I was gonna use a sort of rng to have enemies decide what attack to use, but if I wanted to give it more intelligence and have it react to the player's strategies and status effects on both sides, would it be a good idea to use a behavior tree or a different method instead?

  • @rebirth4119
    @rebirth4119 Жыл бұрын

    Its really great that nowadays certain game engines use visual node scripting so you can easily isolate the different actions of AI based upon what data is provided to them via the player of the world around them. It allows people to see whole tree and easily make changes when needed.

  • @blackcitadelstudios
    @blackcitadelstudios Жыл бұрын

    Currently deciding which to use on my enemy ai. Finite state machines or behaviour trees. 😅

  • @peremoyaserra2749
    @peremoyaserra27494 жыл бұрын

    One thing I didn't get the 4:11 caching thing . I am making a game where the enemy_director tells each instance of a particular enemy what to do each frame using a (small)behaviour tree. The thing is taht I am traversing the tree and making the pertinent checks every frame; how can I store data about the state in wich it was and still check wether it shoud choose an other path?

  • @jamesostrander8022
    @jamesostrander80222 жыл бұрын

    Any books or websites to check on how to construct a behavior tree using C#? I would love to do this for a game in Unity Engine.

  • @kd45286
    @kd45286 Жыл бұрын

    Everyone thinks of AI but behaviour trees work wonderfully for player states

  • @vanivanov9571
    @vanivanov95715 жыл бұрын

    I wish the graphs were more details, giving examples of the topics discussed.

  • @CommieG
    @CommieG5 жыл бұрын

    Damn, this channel is so underrated

  • @YawLighthouse
    @YawLighthouse5 жыл бұрын

    Will you be at some point going over Utility AI(even though its really IA ;) )?

  • @AIandGames

    @AIandGames

    5 жыл бұрын

    Yeah I think Utility is worth covering. It's not a particularly well understood subject.

  • @RyanScottForReal
    @RyanScottForReal3 жыл бұрын

    Love to have a couple examples before telling us how it works.

  • @arcadeassassin7176
    @arcadeassassin71764 жыл бұрын

    behavior trees could be good for a story driven game. because assuming each character has their own tree they could be programmed to behave in a fashion that is far more consistent with their character for example in a shooter game if a character needs reviving an character who doesn't know them very well will only attempt to revive them if their near by but someone who they are close friends with would immediately drop what they are doing and go out of their way to revive them.

  • @DarthMizaru
    @DarthMizaru5 жыл бұрын

    Not sure if it was explained but I wpuld like to kown how the AI aims to your bodypart in fps games.

  • @AaditDoshi

    @AaditDoshi

    5 жыл бұрын

    Umm, it has nothing to do with this video. BUT. You get the player mesh, get the bone of the body part you want it to SHOOT at. Get the bones position. Tell it to shoot at that position.

  • @DarthMizaru

    @DarthMizaru

    5 жыл бұрын

    @@AaditDoshi he did say to comment what we would like to see in future videos. I was also wondering how the AI doesnt always go for a headshot, moving targets, how to miss, etc.

  • @laseede17

    @laseede17

    5 жыл бұрын

    @@DarthMizaru maybe with probabilities. But good idea for a vid.

  • @burhansancakl351

    @burhansancakl351

    3 жыл бұрын

    @@DarthMizaru because developers want you to feel powerful, it would be boring if ai just headshot you all the day and didnt miss any of its shots

  • @BobTheBob9
    @BobTheBob9 Жыл бұрын

    i believe doom eternal actually uses behavior trees that can be programmed visually by designers, given the advantages it makes sense that they'd move away from 2016's state machines

  • @dmdizzy
    @dmdizzy5 жыл бұрын

    Fix your playlist order before it's too late!

  • @DanZhukovin
    @DanZhukovin5 жыл бұрын

    Is this a re-upload...?

  • @thomasnied7722
    @thomasnied77225 жыл бұрын

    How's about the Director from the Left 4 Dead series?

  • @MrJaaaaake
    @MrJaaaaake4 жыл бұрын

    Can you explain why the AI in most video games is so bad when we've had such big improvements in every other area?

  • @tratbagd4500

    @tratbagd4500

    4 жыл бұрын

    At the moment, and especially for some games, it's not that difficult to implement an AI in a game that can't be beaten. However, this is a turnoff for gamers because it's not fun when you know you are going to lose everytime you play. Games are entertainment and people play them for fun.

  • @dendon3384

    @dendon3384

    3 жыл бұрын

    @@tratbagd4500 I've heard this rebuttal many times before. It's not about an AI that can beat the player, it's about a believable AI. Such as not seeing the same behaviors every time, or the AI taking additional steps to stay alive, or use more tactics than rushing the enemy. There is so much potential, and no one is tapping into it.

  • @eramires
    @eramires3 жыл бұрын

    We need Doctor Sung, to give us positronic brain ^^

  • @undisclosedmusic4969
    @undisclosedmusic49694 жыл бұрын

    Do they learn on the fly? Like you would train a decision tree algorithm using some optimization technique? Also, is there a concept of a "forest" of behaviour trees, like a random forest in decision trees?

  • @AIandGames

    @AIandGames

    4 жыл бұрын

    No they're static. Behaviour Trees are hand-made by designers to solve very specific situations. What you're suggesting - dynamic optimisation of tree-structures for decision making - is more in-line with things like Monte Carlo Tree Search (MCTS) which is only now being used more frequently in video games.

  • @aliquewilliams3080
    @aliquewilliams30802 жыл бұрын

    Behavior trees are certainly more scalable than state machines (even hierarchical FSMs and pushdown automata), but many of the negatives you mentioned with FSM really isn't that true. For example, states are highly reusable, can be composed to contain other states, and can be executed concurrently. Creating new states should be as easy as composing new states together, each handling one small task. Memoisation can also be used with FSM as an optimization technique. They’re not exclusive to trees.

  • @tjrizvi251
    @tjrizvi2512 ай бұрын

    "No children, just parents" Hell yeah SINK life!

  • @matthewboyd8689
    @matthewboyd86895 ай бұрын

    I can't wait till they make AI using simple Venn diagram style of play rather than a behavior tree. And by that I mean the idea of two separate things happening and it figuring out which of the two is best based on experience and behaving more realistically. Like, which path to take The tigher corridor with cover but is the long way Or the wide open space thats direct Depending on how tense the situation it could make those gray area dicisions more realistically. Weve all seen NPCs make dumb decisions because of this lack of understanding gray areas

  • @Restart-Gaming
    @Restart-Gaming2 жыл бұрын

    Great video none of this works in unreal all of it is bought from the asset store ue4 is not setup to do very advance AI

  • @xavdest5481
    @xavdest54815 жыл бұрын

    The root can also be a selector. It doesn't have to be Root->selector, it can be root(selector) where the root is an event in the world that has a selector inside it.

  • @DeathxStrike18
    @DeathxStrike184 жыл бұрын

    You basically explained a simple AI neuron

  • @tabeatamm3594
    @tabeatamm35944 жыл бұрын

    I think your videos can be very informative, but I usually find myself not knowing what the hell you were talking about in the end because it is way too technical for me.

  • @everythingwhatyouwan
    @everythingwhatyouwan4 жыл бұрын

    Summarising: Selector is a question (is this condition satisfied) and sequence is a procedure( do this and that)....... AI is basically questions and procedures.

  • @riley8280
    @riley82805 жыл бұрын

    Bet!

  • @vincentpol
    @vincentpol5 жыл бұрын

    I may be focusing on the wrong issue here, but wouldn't it make more sense to say Behavior Trees are the 'powerhouse' of modern game AI. Clearly the 'cornerstone' of modern game AI is the state machine, which is used to build said powerhouse. I can already sense I'm giving this way more thought that I should. Great video as always.

  • @clovislfrc9881
    @clovislfrc98813 жыл бұрын

    3:02

  • @ls200076
    @ls2000765 жыл бұрын

    oh

  • @pshyco6874
    @pshyco68745 жыл бұрын

    Sabonner

  • @Glockmog2007
    @Glockmog20072 жыл бұрын

    In my opinion state machines are better if you want to make very in depth ai. Yes behavior trees are easier to follow and therefore simpler to debug but you cant have too many different branches before they become a complete mess if you want to add more functionality. State machines are much more scalable. And since I actually write the code rather than using visual tools theyre just as readable to me.

  • @tyridge7714

    @tyridge7714

    2 жыл бұрын

    I'd disagree with this, simple finite state machines(especially if they aren't hierarchical) are equally if not more of a nightmare as massive behavior trees GOAP, HTN Planning, or similar planning techniques however definitely allow you to make AI that isn't a complete mess, if you keep your search space small and compact for planning and delegate more complex conditionals and logic to something like behavior trees. I think the main goal should be to use both behavior trees with other techniques, they all do a good job at something and a poor job at others, so it's a good idea to combine them in a way that makes sense and gets the best of both worlds

  • @vaaz_rodriguez
    @vaaz_rodriguez5 жыл бұрын

    Not again dyslexia... I was expecting to see different trees in games...

  • @localgames1
    @localgames13 жыл бұрын

    @Cyberpunk2077

  • @phobos2077_
    @phobos2077_4 жыл бұрын

    Nothing stopping you from using the same event-driven optimizations in state-driven system. So the whole "performance" argument is kinda wrong. The same about reusability - nothing stops from writing states and transitions in an isolated, reusable fashion. You are comparing the bare bones state machines with real optimized implementations of BT's which is just incorrect.

  • @vast634

    @vast634

    3 жыл бұрын

    The reason to use them is more that non programmers can read and understand them more easily. How performant they run is always down to their implementation anyways.

  • @oldsnake7793
    @oldsnake77933 жыл бұрын

    The fact you put dumb Arkham henchman in the video 😂

  • @piotrr5439
    @piotrr54395 жыл бұрын

    pointless, it is still a FSM just not all transitions are explicitly coded. Easier to debug? surely.

  • @loot6
    @loot6 Жыл бұрын

    You should never execute children.

  • @Patttiat
    @Patttiat4 жыл бұрын

    4 min only explaining how to read this tree???!!! do you think that i´m stupid???

  • @badradish2116
    @badradish21165 жыл бұрын

    behavior trees are a narrativist abomination lmfao

  • @badradish2116
    @badradish21164 жыл бұрын

    this is a terrible idea!! why would this be the most popular method right now??

Келесі