archive by month
Skip to content

BWEB building placement library

Christian McCrave, author of McRave, is writing a building placement library named BWEB. BWEB is C++ and depends on the BWEM map analysis library by Igor Dimitrijevic, and within those constraints should be easy to add to a Brood War bot. It’s currently in beta at version 0.8, finished enough to try out but not yet thoroughly tested.

The idea behind BWEB is to place buildings not one at a time like most bots, but in compact predefined “blocks” of several buildings of different sizes. A protoss block will include at least 1 space for a pylon plus possibly large spaces for gateways and other large buildings and medium spaces for buildings the size of a Citadel of Adun. From McRave Blocks v1.2 (mentioned in the code):

McRave blocks v1.2

You can think of a block as a sort of macro for buildings. There are 2 ideas behind it: First, building placement can be compact. Bots that place buildings one at a time often leave space around each building for units to pass through, wasting room and filling up the main base. (ICEbot is a notorious example; its buildings tend to spill out of the main.) BWEB only has to leave space around each block. Second, the library itself can be faster, because it has to choose the locations of a small number of larger blocks rather than a large number of smaller buildings.

Here is the key part of the API, how to get a location for a building:

	// Returns the closest build position possible for a building designed for anything except defenses, with optional parameters of what tiles are used already and where you want to build closest to
	TilePosition getBuildPosition(UnitType, const set* = nullptr, TilePosition = Broodwar->self()->getStartLocation());

	// Returns the closest build position possible for a building designed for defenses, with optional parameters of what tiles are used already and where you want to build closest to
	TilePosition getDefBuildPosition(UnitType, const set* = nullptr, TilePosition = Broodwar->self()->getStartLocation());

	// Returns the closest build position possible, with optional parameters of what tiles are used already and where you want to build closest to
	TilePosition getAnyBuildPosition(UnitType, const set* = nullptr, TilePosition = Broodwar->self()->getStartLocation());

It’s simple enough; ask for a building location, get one. BWEB also has a method to fetch a wall to place in the natural choke, and various utility and debugging methods.

A comment in the code may be a to-do list:

	// Currently missing features:	
	// - Counting of how many of each type of block
	// - Defensive blocks - cannons/turrets
	// - Blocks for areas other than main
	// - Variations based on build order (bio build or mech build)
	// - Smooth density
	// - Optimize starting blocks

thoughts

Gaoyuan Chen’s grid of protoss buildings is similar in idea to BWEB’s blocks of buildings. Unlike BWEB, Gaoyuan Chen places medium buildings in large spaces (and it doesn’t seem to be a problem). In the picture, buildings off the grid are enemy proxies:

Gaoyuan Chen’s building grid

BWEB seems suitable for protoss and terran building placement. Zerg building placement has different requirements and doesn’t seem like a natural fit with the block technique. Sure enough, in the BWEB code I see plenty of special cases for terran and protoss, and no mention of zerg. Of course, terran and protoss benefit from compact building placement. Zerg has less space to place buildings, since they have to go on creep, but also has fewer buildings to place.

How does BWEB ensure that the mix of small, medium, and large building spaces fits the mix of buildings you will create? I got the impression that if, say, you want to (or later in the game end up wanting to) create many gateways (large) and fewer than usual tech buildings (mostly medium), then BWEB will pre-allocate blocks with more medium spaces than you finally use. That doesn’t sound like much of a problem, though.

It’s new software, and many features you might want are not there, at least not yet. You may want tech buildings in remote parts of your base so they are safer and harder to scout, and production buildings near the ramp. You can do that with the “build closest to here” feature, but you may have to take extra care to place pylons ahead of time. The wall feature is very limited so far. The game gives us many uses for complete or partial pylon walls and for supply depots as obstacles. There’s no apparent support for proxies or gas steals; you’ll have to use your own code. The same for spotting pylons or blocking the opponent’s natural with an incomplete engineering bay. And of course there are inherent limitations to the idea of predefined blocks of buildings. A predefined block is never quite optimized for the exact terrain and matchup and build order and so on.

Still, it seems fast and easy, and it’s an improvement over what most bots do today. It should be well worth trying out for a protoss or terran bot, especially if you already use BWEM.

Thanks to the author Christian McCrave for letting me know about it!

Trackbacks

No Trackbacks

Comments

McRave on :

Great write-up, hit the nail on the head, Chen style placement was a big influence for it! The BWEB dev branch has some exciting changes including defensive positions for all bases. I've added McRaves walling logic and improved on it to add cannon positions into the mix, as well as a reserved set of tiles for a path leading out of the main to prevent walling in.

MicroDK on :

As Jay write, I do not think it can be used for zerg. Also, how will the library know which buildings the bot will use for a game? For zerg at least, this purely depends on the opening strategy, which will be know, but also the opponent.

Jay Scott on :

BWEB only makes sure it has spaces for any size building you might want to place. That would be difficult for zerg, because the library can’t know ahead of time where the creep will extend. When and where will you build hatcheries or creep colonies? The bot may not know itself until it suddenly needs one.

McRave on :

What is possible however is zerg walls at natural as long as a macro hatch exists near the chokepoint. Could still add tiles and have checks for creep before returning anything. If it's something you'd find useful I can add it for sure.

Jay Scott on :

What I have in mind for Steamhammer is a more general placement planner that also figures out where to set up siege tanks and where to burrow lurkers. But other zerg bot authors are probably less ambitious—you may want to collect opinions.

MicroDK on :

Absolutely! It could very useful for walls. Could it be used for creating simcity and placing spores/sunkens?

McRave on :

Definitely, same logic that McRave uses for FFE, would just need to modify placements based on race. Here's how a FFE looks, it has a path which can't be placed on, set positions for a gate, forge and cannons all which don't overlap bases or mining.

https://m.imgur.com/KvH8Nzb

MicroDK on :

Guess you also need to modify block sizes based on races... I think sunkens/spores are smaller than cannons or pylons. Make room for at least 6 sunkens and put spore close to mineral. Yes there are mny things to consider. :)

MicroDK on :

But it could be used for one thing with zerg: Making a simcity of a certain size. :)

MicroDK on :

But anyway, I think it is a great idea, and for new (and old) bot authors they get yet another free library to use. :D

Marian on :

Things to consider for regular buildings:
- place your building close to as many friendly buildings as possible
- place your building close to impassable areas
- keep your building out of mining area(unless it's purposefully placed static defence)
- keep vulnerable tech as far away from opponent as possible
- track at least one path from your production buildings to closest opponent building(or map center)
- advanced: map specific sim city templates(especially vs zerg and protoss)

McRave on :

So far: it checks for a simple path from natural choke to main choke, returns build position of closest block (so it clusters buildings), avoids placing in mining, avoids overlapping any neutrals, static buildings, walls and bases. I'll be adding hidden tech capabilities in the future.

Sim city is a WIP, as I mentioned above, check out: https://m.imgur.com/KvH8Nzb

McRave on :

One last comment, BWEB has a separate Git, any suggestions or testing is welcomed! Thanks again Jay!

https://github.com/Cmccrave/BWEB

Jay Scott on :

I’ve updated the post with the link.

Add Comment

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Form options

Submitted comments will be subject to moderation before being displayed.