We've made a little video talking about how the AI will determine where it should place defences. It uses a Voronoi diagram to first determine places in between houses and buildings, and then generates circles from that to find an optimal location to place a defensive structure.
(If you cannot hear the audio, watch it on Youtube. Uploading it here seems to have muted the audio greatly)
(Again, if you cannot hear the audio, watch it on Youtube here)
If you are interested in detail how it works, Brent wrote up a whole tutorial on Voronoi diagrams and AI that you can read about here.