Keep in mind that this is not even what you want. Consider a tower T with an attack range T
..t.. .ttt. ttTtt .ttt. ..t..
and a branching map, where there is one narrow direct path and one wide indirect path from point A to point B Suppose that the closest points around A marked by n are accessible, but not capable of building towers.
xBxxxxxxx x.......x x.......x x.......x x..xx...x x..xx...x x..xx...x x.......x xnnn....x xnnn....x xAnxxxxxx
Initially, the characters will follow the path p
xBxxxxxxx xp......x xp......x xp......x xp.xx...x xp.xx...x xp.xx...x xp......x xp......x xp......x xA.xxxxxx
Placing T at the narrowest point will result in 3 beats if the characters continue along the same path. But this is not what happens if the tower pain is high relative to the speed goal, for example. Of course if fatal. Instead, characters will be redirected to a longer path.
xBxxxxxxx xp......x xppppp..x xt.p..x xttxxp..x xtTxxp..x xttxxp..x xt.p..x x....p..x xppppp..x xA.xxxxxx
The best placement in this case is one that guarantees at least one hit. (Keep in mind that the best placements T closer to A are considered unremovable.)
xBxxxxxxx x.......x x.......x x.......x x..xx...x x..xx...x x.txx...x xttTtt..x x.ttt...x x..t....x xA.xxxxxx
So, you may need a T placement that maximizes the cost of the minimum cost path that will be calculated after the T placement. Look at the maximin (minimax) algorithms. Of course, there are other things that should be considered when placing, for example, the security of the tower itself.
source share