Code: Select all
do something (mostly based on enemy distance and health)
if not carry
if enemy short range
else if enemy medium range
else if enemy long range
else if enemy out of range
else if no enemy
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?