I've made several enhancements to the article, refining both the description and the code. I hope you find it interesting.
https://aalmada.github.io/posts/Behavior-tree-development-in-csharp-with-IEnumerable-and-yield/
#dotnet #csharp #unity3d
Behavior Tree Development in C# with IEnumerable and Yield

As discussed in a prior post on custom iterators with yield in C#, the combination of IEnumerable<T> and yield enables the creation of coroutines. Coroutines are commonly defined as functions capable of pausing and resuming execution. Effectively, managing these entails employing state machines, easily implemented through the use of the yield keyword. However, a challenge arises when composing multiple reusable coroutines, a problem addressed by the concept of behavior trees.

Antão Almada’s Blog
@antaoalmada Behavior trees area a real pain for me, really thanks for the article, I hope to increase my skills after reading your article 😍
@ciaxeres I’m pleased that you found it valuable. The article primarily emphasizes implementation details, rather than their practical usage. However, comprehending these internal workings should enhance your overall understanding of them.
@antaoalmada i made my first contact with BT this month and a lot of things wasn't clear for me I think some "human text" may help me better than a technical manual book
@ciaxeres BTs and coroutines in Unity are based on the 'yield' keyword. I also have an article explaining how its internals work. Looking at the article now, I've just now noticed that I forgot to not lazy evaluate the parameter validations for the BTs. I'll have to update the code... 😅
https://aalmada.github.io/posts/Building-custom-iterators-with-yield-in-csharp/
Building Custom Iterators with ‘yield’ in C#

As detailed in a previous article, an enumerator serves as a representation of a pull stream. To obtain the next item, clients must invoke the MoveNext() method. If it returnstrue, it indicates a successful retrieval, and the value can be accessed through the Current property. The enumerator is typically implemented as a state machine, encompassing information about the current position within the stream and the current value.

Antão Almada’s Blog
@ciaxeres I have now fixed the lazy evaluation of the parameters validation in the BTs article. Please check the updated version.