There are other forms of AI available. In this book, we created the basic AI. In the hierarchy of the components, there is a controller. The controller then decides which Behavior Tree to run. Then, tasks are chosen based on the sequence of decisions in the tree.
In the controller, we could have an array of different Behavior Trees suited for different tasks. Then, once we approach the task, the tree contains the subtask which aids in coming to a solution. Introducing this level of abstraction requires understanding of which state is necessary to enter.
We demonstrated how to create an AI basic enough to run indefinitely. Using math, we were able to help the AI avoid contacting walls. Presumably, this is all you need for some scenarios. If you need your units to all run independently of each other and avoid the walls as necessary, this script will be perfect for you. However, if you need more control over your units, you can't achieve it with this technique alone.
The alternative...