Removing units that block paths

Removing units that block paths
0

#1

In my newest algo, I realized that when there are enough enemy attacks, my defense becomes a barrier, effectively blocking both me and my opponent’s units.


Do you guys have any idea on how to remove units that block unit paths?


#2

A good check on whether or not a placement blocks off a path is to add the unit to the game map then run the pathfinder to get the new path. If you iterate over the path and discover that none of the locations are on the enemy side (y >= 14), then you almost certainly blocked off your own path. You could then remove that unit from the game map and look to place elsewhere.

If you’re actively trying to block things off and open it again, then it’s best to keep track of where you plugged things up so you know where to remove. You could use the check above as a method of figuring out what placement closed things off, so the next turn your algo knows where to start poking around to open things up again.


#3

For this I make use of hardcoded plugs. I actually never block of the entire path for the opponent, as I find it much more easy to control where the opposing units go if you leave the options open. An easy solution would be to use hardcoding to exclude a few coordinates from firewall placement. Good luck!