If you are interested in learning AI and how it can be used in #gamedev, you should start with BEHAVIOUR TREES! 🌲🧠

As the cornerstone of game AI, BTs are used in:

• Halo 2 🪖
• Bioshock 💉
• GTA V 🚗
• Façade 🍈
• Alien: Isolation 👽

Let's see how they work! 👇

🧵
Many of you are familiar with FINITE STATE MACHINES: the most popular pattern for character controllers.

While FSMs are graphs, BTs are (unsurprisingly!) trees. 🌲Their leaves are the ACTIONS 🦾 and PERCEPTIONS 👁️ your agents can perform and sense.
Each node in a BT can be in any of the three following states:

✔️ SUCCESS: the node was executed successfully
❌ FAILURE: the node could not be completed
⏳ RUNNING: the node is still being executed
The nodes that are not leaves (=composites) control the "flow of execution", deciding which ACTIONS and PERCEPTION are going to be be executed.

There are two main types of nodes:
• SEQUENCE: succeeds if all of its nodes succeeded
• SELECTOR: fails if all of its nodes failed
Let's see how the SEQUENCE node works, with a simple example.

Let's built a BT to control WALL-E. The robot keeps searching, collecting and disposing of any rubbish it could find.

As long as all three actions succeed, the SEQUENCE is successful. ✔️
On the other hand, even if only just one of those actions fail, then the entire SEQUENCE fails... ❌
The SELECTOR node works in a "complimentary" way. The children nodes are executed until one succeeds. ✔️

SELETORS are used to provide a series of alternatives for a specific task.
For a SELECTOR to fail, all of its children nodes must fail. ❌

This means that the task the SELECTOR wanted to achieve could not be executed.
SELECTOR and SEQUENCE nodes can be used to build complex BTs.

This, for instance, shows how to build an AI that can open doors and move into rooms. 🚪🔑

The SEQUENCE contains all of the "steps" necessary, while the SELECTOR provides alternative a series of ways to open a door.
There is so much more to BEHAVIOUR TREES than just what I have shown here! In the next few days I will be posting more, including some code! 👨‍💻

In the meantime, @AIandGames has made a gentle—yet comprehensive—video about BTs that is worth watching!
✨ 𝘁𝗵𝗮𝗻𝗸 𝘆𝗼𝘂 𝗳𝗼𝗿 𝗰𝗼𝗺𝗶𝗻𝗴 𝘁𝗼 𝗺𝘆 𝘁𝗲𝗱 𝘁𝗮𝗹𝗸 ✨

If you enjoy content about gamedev, shader coding and artificial intelligence, feel free to retweet & follow me for more! 😎

And stay tuned for the next part about BT! 🌲🧠
You can follow @AlanZucconi.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled:

By continuing to use the site, you are consenting to the use of cookies as explained in our Cookie Policy to improve your experience.