This is a theoretical approach, so you'd have to code this yourself, but what I would do is iterate through each position on the map, or a reduced portion of the map if you wanted to limit the positions to those along a road or areas where the entities would approach. When you look at a tile, make sure it doesn't have blocking scenery, or is being occupied by an existing tower. Then using that tile and the tower's range, I would calculate the top/left most tile within its circle, and the bottom/right most tile within its circle. I would iterate through those tiles and add a score for each tile that is road. Store this score and the tile you are testing your tower on together. At the end of testing all the tiles on the map, you then iterate through all the tested tiles which contained a score and find the highest score. It there are tests that had the same amount of road, then randomly pick. But this is your optimal tower position. Obviously this is theoretical because I don't have your code here, so you have the hard part. I wish you all the best.