Count "free slots" around an energy source?
-
Does anyone know how to count the # of free slots around an energy source? I want to know both w/ creeps blocking the path and without. i.e. count "walkable" areas that are not blocked by immobile objects.
-
There are a lot of different ways of how to do this. One possiblility (i use a deviated version of this) is the follwing: (You don't necessarily need a flag, but I think that flags help you a lot.)
Initial effort (probably only needed once):
1. Place a flag on the source
2. Room.lookAtArea( Flag.pos.y-1, Flag.pos.x-1, Flag.pos.y+1,Flag.pos.x+1)
3. check terrain and structures of the returned positions and save all walkable tiles to the flag memory
Subsequent requests:
simply get flag memory and check, if the walkable tiles are occupied by creeps
don't forget to update the flag memory should you build a structure near the flag