Mix of experience and understanding mechanics. There are times when the 2 contradict each other though... I still don't understand why fire breath is not used immediately by gloom under night when hit by a Sniper, as theoretically it'll do that right away, but most snipers will say otherwise when you ask any of them.
But it's things like this with all the required planning to beat the AI that makes PvM interesting and fun (for me)~