From alpha 4.x to alpha 5.3.1 there were no subroutines, and I organized my trees in "departments" or blocks according to invariant conditions.
So now that I have finally some minutes to relax (I got a not so easy start with the little one) and I was thinking to refactor the AIs in subroutines but, well, mostly it is not needed. For the moment it is easier for me to have all the block of actions in one program. What is more interesting is when I want to activate/deactivate complete behaviors of a bot.
Like a bot that behaves like a fighter/collector and then behaves very conservative. So actually more than using subroutines for little part of the program is like I use subroutines to switch "mode" of the bot. That's means that the subroutine has exactly the same structure of the parent program, to let the bot behave differently.
Instead how do you use them? Do you pack little part (like collecting resources) of the bot behavior in subroutines and then you assemble them in one program?
Code: Select all
if carry
do something (mostly based on enemy distance and health)
if not carry
if enemy short range
do something
else if enemy medium range
do something
else if enemy long range
do something
else if enemy out of range
do something
else if no enemy
capture resources
So now that I have finally some minutes to relax (I got a not so easy start with the little one) and I was thinking to refactor the AIs in subroutines but, well, mostly it is not needed. For the moment it is easier for me to have all the block of actions in one program. What is more interesting is when I want to activate/deactivate complete behaviors of a bot.
Like a bot that behaves like a fighter/collector and then behaves very conservative. So actually more than using subroutines for little part of the program is like I use subroutines to switch "mode" of the bot. That's means that the subroutine has exactly the same structure of the parent program, to let the bot behave differently.
Instead how do you use them? Do you pack little part (like collecting resources) of the bot behavior in subroutines and then you assemble them in one program?