5 minute Behavior Tree tutorial
5:16
Пікірлер
@wongfeyhuang4163
@wongfeyhuang4163 6 күн бұрын
thx yu
@petterogren7535
@petterogren7535 6 күн бұрын
You are welcome!
@kawaiianthony8090
@kawaiianthony8090 28 күн бұрын
Wanted to Behavior Trees to develop my game's AI, but my thought process is still stuck at using FSMs, this tutorial is very useful!
@petterogren7535
@petterogren7535 25 күн бұрын
I'm happy to hear that!
@parswarr
@parswarr 2 ай бұрын
What is the software package you used for this video which has the virtual environment and the real-time BT in the sidebar?
@petterogren7535
@petterogren7535 2 ай бұрын
The virtual environment is the game engine Unity 3d. And the BT package used is Panda BT (the free version).
@MaartenVergouwe
@MaartenVergouwe 3 ай бұрын
At 24:00 you introduce a small heater behavior tree but I think there's a mistake in the condition. It should be T<T0 for the Heater to turn ON and not T>T0.
@RPG_Guy-fx8ns
@RPG_Guy-fx8ns 4 ай бұрын
If actions have to plan around pre conditions and post conditions, It ruins any modularity. You can't just use a generic FreePathToObjectExists() behavior or a generic MoveToObject() behavior... You would need custom variants, like SafeFreePathToObjectAndGoalExists() and SafeMoveToObject(), so those actions don't make plans that cause oscillations by breaking earlier rules. Sometimes, you can't really break down the problem into parts that only focus on individual tasks, some problems require planning the entire route. You need A* pathfinding that labels hazard areas, and it would need to understand how holding an object effects the size of the robot, and it would need to understand how each action effects the paths to all parts of the plan. if Move to object needs to know the entire behavior tree, what is the point of a behavior tree? you will just have to hardcode MoveToObject every time you change the tree.
@nikodromikro
@nikodromikro 5 ай бұрын
you explain very well can you do tutorial on Utility AI as well?
@SoulGuitarMetal
@SoulGuitarMetal 5 ай бұрын
I was having problems designing long-running actions. Should they check for conditions themselves to continuing to run? For example, the "eat" subtree checks each tick and fails if there is no more food. But seeming this video, makes sense that the condition checks should take place outside, in the sequence instead, so that "eat" does not execute again if there is no more food. Is that right?
@DeyuZhang-vy3gk
@DeyuZhang-vy3gk 7 ай бұрын
Great video! Is this project open-sourced?
@lamtengfoong3599
@lamtengfoong3599 8 ай бұрын
Hi Professor, thank you for the great talk. I have a question: If behaviour trees have essential cyclomatic complexity of 1, and in your book section 2.2.3 you prove that a FSM can be rewritten into a BT, does that mean that FSMs also have an ECC of 1 as well? Additionally, I noticed that that the BT in section 2.2.3 there is an additional global state variable storing the current state. Does having a black board or global variables somehow break this ECC=1 proof for BTs?
@lewiscianci1980
@lewiscianci1980 8 ай бұрын
2.7K views and no comments, wow! This helped me immensely. It's very well put together, great work!
@munumun
@munumun 8 ай бұрын
26:00 magick
@coverdiaries2821
@coverdiaries2821 9 ай бұрын
Amazing explanation. Thanks!
@anuraagchandra2548
@anuraagchandra2548 10 ай бұрын
The volume is low and it ruins the video. Please take care of this issue.
@anuraagchandra2548
@anuraagchandra2548 10 ай бұрын
Extraordinary explanation.
@isitsou
@isitsou Жыл бұрын
First of all, great series of videos, you describe complex designs in a great and very understandable way. Thank you! I believe that you should clarify in the video that you talk about "Deterministic" FSM vs BT. I would like to know your opinion about non-deterministic FSM vs BT. Which are the pros and cons in that comparison?
@abhishekarvind
@abhishekarvind Жыл бұрын
Great Video! Is there an algorithmic or simple way to check these bugs for large behaviour trees?
@ludvigericson6930
@ludvigericson6930 Жыл бұрын
At 24:16 are we to understand Eq (5) as the union of all Kbar_j's s.t. the condition holds? Otherwise it is a set of subsets of U.
@petterogren7535
@petterogren7535 8 ай бұрын
Sorry for the late reply, only saw this now. No, not the union of different Kbar_j's, only the one for which the stuff to the right of the ":" holds. That is, it is non-empty, it is either j=k, or it is such that the next one is empty.
@metaroonlabstech
@metaroonlabstech Жыл бұрын
Damn!
@bommijn
@bommijn Жыл бұрын
Very informative videos, Thank you!
@liuwz
@liuwz Жыл бұрын
Thank you very much for the series of videos, it is extremely helpful! However, I noticed that only the first part has subtitles, the other videos do not have subtitles, is it convenient for you to add this? thanks again!.😀
@noenernet
@noenernet Жыл бұрын
Thank you, very clear compared to other explanations I've found. The book was even more handy. I have noticed a couple similarities between different algorithms - pre- and post-conditions, priorities (utility functions). Any future plans for a BT vs GOAP video address these? I also love how you can nest different algorithms, eg BT / GOAP on FSM, or a purpose built a* pathfinding library on a BT.
@iNomanWaleed
@iNomanWaleed Жыл бұрын
Hey Sir @Petter How to connect with you?
@izzetemrecetin
@izzetemrecetin Жыл бұрын
Great video. Thanks for sharing
@lukemarvelous
@lukemarvelous Жыл бұрын
Thank you for sharing!It means a lot to me.
@peterhayman
@peterhayman Жыл бұрын
awesome talk, thank you ❤❤
@player-eric
@player-eric Жыл бұрын
Thank you for the video. This theory introduced in the video is very interesting, but I have a question. Even if an infinite loop is detected in the BT analysis, it does not necessarily mean that the BT is problematic, am I right?
@petterogren7535
@petterogren7535 Жыл бұрын
That is correct. An infinite loop might be part of the desired design. Such as a lawn mower robot that switches back and forth between recharging the battery and mowing the lawn. Assuming the lawn keeps growing, the job will never be "finished", and that is ok. A similar situation is vacuum cleaning, and the patrolling of security robots. But in some instances it is a problem. If you ask a robot go get you a glas of water, you don't want it to be stuck in an infinite loop somewhere along the way.
@player-eric
@player-eric Жыл бұрын
I appreciate your response.
@lln6123
@lln6123 Жыл бұрын
nice!
@player-eric
@player-eric Жыл бұрын
The video mentioned, "If during that search a person came by a person nearby was suddenly returned success and the agent would stop searching and ask the person if the person could please open the door.". I'm not sure how this could be implemented using py_trees. I think this involves parallel processing, interruption. Could you please elaborate on this?
@petterogren7535
@petterogren7535 Жыл бұрын
You need to have reactive versions (without memory) of both the Sequence and Fallback nodes. Unfortunately, some software has memory nodes as default. Sometimes this is a simple option, otherwise you have to use a workaround. In Panda BT you have to "reset" the BT every tick to remove the memory.
@player-eric
@player-eric Жыл бұрын
@@petterogren7535 Thank you for your reply. I am currently more familiar with Python, and I have hardly used Unity, so I has little knowledge about the usage of Panda BT. I am currently learning py_trees. What I actually wanted to say is that, for a single `tick()` of a BT, I feel that the traversal of the entire tree should be serial, maybe depth-first traversal. If so, then BT has already executed to "Has a key", then even if "a person came by" at this time, I feel that BT will not go back to "confirm that a person nearby was suddenly returned success", but will continue to "Search door mat / garden", unless there is a parallel mechanism that allows another subprocess to constantly detect whether "a person came by".
@petterogren7535
@petterogren7535 Жыл бұрын
Yes, a single tick traverses as you describe, but the next tick starts from the root. So the next tick can respond to the presence of a person and act accordingly. @@player-eric
@player-eric
@player-eric Жыл бұрын
​@@petterogren7535 Thanks sincerely for your guidance.
@mohokhachai
@mohokhachai Жыл бұрын
And how selector choose best Action depending on or ? Or cost
@mohokhachai
@mohokhachai Жыл бұрын
Or we use random decorator
@mohokhachai
@mohokhachai Жыл бұрын
Or we add new type of decorator
@petterogren7535
@petterogren7535 Жыл бұрын
Hi Mohakhachai! Yes, it can depend on a cost estimate, or an urgency estimate. If for example, the children nodes are created using reinforcement learning, they have a value function estimating average future reward, this can be used to pick the best option.
@1volkansezer
@1volkansezer Жыл бұрын
Great video, thanks. But I have a confusion. In the last example (the burglar one), the solution to avoid the contradiction problem is adding a "Hide Camera" action to the right. But in this case, as long as the action of "turn light off" action is made, the rightmost "hide camera" action will still not be taken? Doesn't that mean the contradiction continues? Was the "Turn Light Off" action supposed to be deleted when adding "Hide camera"? Is there something I am missing?
@petterogren7535
@petterogren7535 Жыл бұрын
Hi Volkan! Thanks for your question. Yes, I think a was a bit unclear around 18:28. As you note, for the fix to work you need to either disable or remove the "Turn light off", or add "Hide camera" to the left of "Turn light off". Thanks for pointing this out!
@1volkansezer
@1volkansezer Жыл бұрын
Hi Petter. Thank you for making a video series so clear and understandable that even a small mistake can be noticed :).
@siarheipilat8152
@siarheipilat8152 Жыл бұрын
The fact that you are giving out this knowledge for free is simply amazing. This is pure gold, thank you so much!!
@petterogren7535
@petterogren7535 Жыл бұрын
Hi Siarhei, I'm glad you found the videos useful. Best regards, Petter
@jayvatar
@jayvatar Жыл бұрын
Thanks, I have a few questions if you can help understand better. Q1) You indicated that the eat banana was running and this state is returned to the fallback (selector) ancestor. During the subsequent execution of the tree where does the execution start? Does it start at eating the banana (running state) or does it restart with the left branch (eat sandwich / eat apple) all over again or somewhere else? Q2) If the subsequent tree execution starts at eating the banana, how would one allow for interruptions for eating the banana since it now starts at eating the banana? Wouldn't you have to process before this to catch interruptions (ooops turns out banana is bad inside or spouse calls you from the other room) ? Q3) Is the execution of the tree always completed in a single loop of the main sequence of the program? Let's say this is in Unity engine, would the tree execution completed in a single Update? Thanks for video!
@petterogren7535
@petterogren7535 Жыл бұрын
Hi Jayvatar. Q1: The execution of a BT always starts from the Root node. Otherwise you would not have any reactivity, such as the possibility to react to a fire alarm while you are eating. There is an old version of BTs used by some, that does not include the "running" and always executes a node until it either succeeds or fails, but as noted above, it has significant drawbacks. Q2: You are right, if it didn't start from the root, interruptions would not work.
@jayvatar
@jayvatar Жыл бұрын
@@petterogren7535 Great ok, thanks for clarifying that :)
@easyBob100
@easyBob100 Жыл бұрын
Darwin never said "survival of the fittest". Also, if you want to do crossover on things like FSMs, try using the NEAT algo. If it works for NNs, it should work with any other tree structure, don't ya think? :)
@YOSFP
@YOSFP Жыл бұрын
Thank you Petter, it was very insightful
@hype._.
@hype._. 2 жыл бұрын
Thank you.
@davidlakomski3919
@davidlakomski3919 2 жыл бұрын
Wonderful thanks!
@kaanozdemir9627
@kaanozdemir9627 2 жыл бұрын
İs This Unreal Engine Behavior Tree?
@petterogren7535
@petterogren7535 2 жыл бұрын
Hi Kaan. The video describes the general concept of Behavior Trees. There are many implementations: some tailored for Unreal Engine, some for Unity3D, some general implementations for Python, some for C++ and so on. There are some differences between different implementations: Sometimes the Fallback node is called a "Selector", sometimes nodes have memory (I think this is a bad idea as it reduces reactivity, as explained here: kzbin.info/www/bejne/jWjTZGennaeorpo). It seems that the creators of the Unreal BT have described some of the ways their implementation differs from the "standard" under the heading "Differences in Unreal Engine Behavior Trees" found here: docs.unrealengine.com/5.1/en-US/behavior-tree-in-unreal-engine---overview/
@kaanozdemir9627
@kaanozdemir9627 2 жыл бұрын
İs This Unreal Engine Behavior Tree?
@petterogren7535
@petterogren7535 2 жыл бұрын
Hi Kaan. The video describes the general concept of Behavior Trees. There are many implementations: some tailored for Unreal Engine, some for Unity3D, some general implementations for Python, some for C++ and so on. There are some differences between different implementations: Sometimes the Fallback node is called a "Selector", sometimes nodes have memory (I think this is a bad idea as it reduces reactivity, as explained here: kzbin.info/www/bejne/jWjTZGennaeorpo). It seems that the creators of the Unreal BT have described some of the ways their implementation differs from the "standard" under the heading "Differences in Unreal Engine Behavior Trees" found here: docs.unrealengine.com/5.1/en-US/behavior-tree-in-unreal-engine---overview/
@ruibotu680
@ruibotu680 2 жыл бұрын
The comparison and criticism about RL are just amazing. Looking forward to seeing the improvement of RL methods with behavior trees.
@Telokis
@Telokis 2 жыл бұрын
Thank you very much for the series of videos, it is extremely helpful! I have a remark, though: I do not really understand the concept of "RUNNING" actions. If the ticking is synchronous, the action won't return anything before it's finished, right? At that point it will know whether the action succeeded or failed. And if the action is asynchronous and return RUNNING because it's basically doing work in another thread, that means we can't as easily rely on the tree for interruptions because we need to stop the thread or at least alert it. To take the examples from the video: if I'm eating the banana and the alarm suddenly rings, I won't instantly drop the banana and start leaving the building. I'll have some kind of "stop" effect that will let me cancel/pause the "Eat banana" action. Doesn't this basically bloats the complexity immensely in real-life behavior trees? I feel like I really am missing something, there. Does the tree need to "remember" what task is currently running so it can tick it again next time? That would prevent interruptions from working at all but it really feels like interruptions are not as straightforward as what the video says when we try to think about the practice.
@petterogren7535
@petterogren7535 2 жыл бұрын
Hi Telokis. Thanks for your questions. If you want to know more about real applications you might want to check out the PlanSys2 video here: kzbin.info/www/bejne/emirnHtsiNukoLs As you might have noticed, there is one "version" of BTs that does not include the "Running", where basically all actions are allowed to terminate (returning Success or Failure) before another action starts. However, as you note, this makes reactivity impossible, so I think this version is crap. In principle, I would say that if there is reason to believe that my life is in danger, I would indeed just drop the banana and start leaving the building. A banana on the floor might look a bit messy, but it is not that bad compared to dying in the fire. Another example where there is a bigger need for "gracefully terminating an action" is if you are driving a car when alarm goes off (imagine someone told you there is a bomb in the car). Just getting out of the car at full speed would probably kill you. Here I would say that the responsibility for stopping the car should be with the "get out of car" action. "get out of car" should have a precondition of "very low speed" and if that is not satisfied it would first slam the brakes, and then get out. (Check the video on Backchaining to see how preconditions and postconditions can be used to build the BT). One drawback of this "goal directed" approach is that you would only execute actions needed to reach your next goals, and not tidy up after you. When you are done eating, you just leave the table, not putting dishes back in the sink. This can be addressed by explicitly adding the goal of "having a tidy home" to the BT (again using backchaining). In some sense it comes down to your implementation. You might have a robot system where an action executes motor commands in a really high frequency control loop in a separate process, and if you stop sending new motor commands, the hardware might just stick to the last given command indefinitely, causing something to brake. In such cases, if you implementation really requires that an action is "stopped" before another one is "started", you might just add a middle layer to your design keeping track of "current" and "next" action. The BT then keeps sending this layer an instruction of what should be done next. In the example the new command is "leave building", then the layer knows that it is currently executing "eat banana" and thus sends a "stop" message to "eat banana", waits for confirmation of a proper stop and then sends a "start" message to "leave building" and updates its notion of "current" to be "leave building" and "next" to be "(empty)". As long as "next" is empty, the current one is allowed to run. With this design, if stopping an action takes a long time, it might be that "next" is replaced by something else by the BT before "current" can confirmed its stop. Such a layer would not be overly complex.
@Telokis
@Telokis 2 жыл бұрын
Thank you very much for those videos, they are very helpful!
@NathanDortman
@NathanDortman 2 жыл бұрын
Were at the age where CompSci lectures feature phrases like "Kiting Strategy" :)
@Killofamas
@Killofamas 2 жыл бұрын
Could we implement some kind of parallel container that would act as a « memory » that would record each time we check for a condition both its result and it’s time of verification ? We could then use this memory when a simple belief is needed and actually check it when this is really important to have fresh data. Moreover, when only the belief is needed, we could have a subtree checking quickly how recently has this checked occurred and, if « good enough », trust it as such, if not, check it For the example you used about the closed door before going to bed, if I remember closing the door 15 minutes ago, even though it’s very important, I’m still confident enough that the door is indeed closed, if I haven’t checked the door for the whole day, I might want to check it
@petterogren7535
@petterogren7535 2 жыл бұрын
Good point, I think your suggestion makes sense. Best, Petter
@Killofamas
@Killofamas 2 жыл бұрын
It kind of sounds like BTs are the perfectly refactored form of an optimal FSMs…
@kvnptl4400
@kvnptl4400 2 жыл бұрын
Thanks for the easy explanation 👍
@thaos5499
@thaos5499 2 жыл бұрын
hi, i'm little late to the series, I'm just wondering what happens if the time taken to compute the success, failure or running status in a leaf is more, what will happen if it can't able to maintain the frequency of the ticks?
@petterogren7535
@petterogren7535 2 жыл бұрын
In these cases it is definitely a good idea to run the update of the conditions in a separate process, running in parallel to the BT execution. The the BT would react to the best available information so far (perhaps computed a few ticks ago), but once new information arrives, the BT will react to it in the next tick.
@thaos5499
@thaos5499 2 жыл бұрын
@@petterogren7535 I understand, that makes sense. I'm trying to design the Behaviour Tree for a robot and I couldn't find proper tutorials on Behaviour Trees, ur tutorials are really good and very helpful, thank you very much for making this series. :)
@petterogren7535
@petterogren7535 2 жыл бұрын
@@thaos5499 I'm glad you like them!
@adrian5837
@adrian5837 2 жыл бұрын
ᑭяỖmo𝓼𝐦 ❤️
@kimochisaiko6442
@kimochisaiko6442 2 жыл бұрын
Oh men this is the best tutorial ever!!!
@kimochisaiko6442
@kimochisaiko6442 2 жыл бұрын
great material!!!!
@petterogren7535
@petterogren7535 2 жыл бұрын
Hi Kimochi, I'm glad you liked it!
@nolangutierrez9572
@nolangutierrez9572 2 жыл бұрын
I started watching your video without realizing you were the actual author of the book. Thanks for putting your time into this. It might be a bit much to ask for but I would highly appreciate an explanation of the section in your book on stochastic behavior trees. I have studied stochastic processes in the past, but it's still a bit dense for me. Thanks for the video.