There is already a topic on this for defense. At the start a random number from 1,2 or 3 is chosen. This gives the charge when the ninja fires. After the special is cast a new random number from 1,2 or 3 is chosen and so on.
I assume it is the same for AI while autoplay.