Finding a Wall

During the Probots tournament some viewers remarked on the building placement of my bot, in particular my wall off. In this post I will show how I find a suitable wall placement for any given map.

Step 1: Where are the ramps?

From the StarCraft 2 API we get two grids that can help us in finding the placement for our wall. The first tells us which squares on the map are buildable, the second tells us which squares on the map a unit can walk on. The below image shows the buildable areas in white for the map CatalystLE. The areas that are not buildable, but which are walkable are shown in red.Ramps.png

Note that for the most part, the red areas correspond to ramps.

Step 2: Finding the ramp out of the main

First we want to determine the area of our main base itself. to do this we find the area that can be reached from our staring point without leaving any of the buildable area. This area is shown green in the below image.


Now we find all of the squares that are part of a ramp and adjacent to the main area. These are shown in orange in the image above. On maps with a pocket expand, we sometimes have two ramps that lead outside of our main. To make sure we pick the correct one, we find the square with the smallest walking distance to the enemy main. This squares is shown as yellow in the above image. This tells us which ramp leads out of our main.

Step 3: Finding the areas to the side of the ramp

Next we take all the squares adjacent to our ramp that are not pathable. We then determine all other unpathable squares that are within a distance of 5 steps of that original set of squares. See the two blue areas in the below image.


Step 4: Finding the possible placement locations for the Gateway and Forge

We now look for placement locations for 3×3 buildings that are adjacent to these two areas so that we can create a tight walloff. We only accept placements inside the area of our main, which we have determined earlier. The allowed placement locations can be seen in the image below.


Step 5: Choosing the final positions

Finally, from these two sets of possible building locations we choose the ones closest together, provided that the resulting placements do no overlap. Then we choose a location for a Pylon that borders both of these buildings. The resulting locations can be seen below.


The wall looks like this in game:


How generic is this solution for finding a wall?

This solution makes a number of assumptions about the map, such as that there exists a single exit from our main, and that this exit is itself a ramp. It assumes that the exit can in fact be walled off by a Gateway, Forge and a Pylon. In practice most ladder and tournament maps satisfy all of these conditions and a suitable wall is found on all of them. For strange, unconventional maps this method will not work very well, although it should be possible to use it as a basis and take these different features into account.

The current version also does not support walling off with buildings of different size (for instance a Barracks and two Depots, or just three Depots). However it should not be very difficult to adept it so that it can handle these.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s