Skip to content

Bunkers

Ben Bartlett edited this page Jan 26, 2019 · 1 revision

This article is an excerpt from a longer blog post I wrote about the evolution of Overmind. Check it out if you're looking for a longer read!

A new base design

The classic “box and flower” layout (like the one in this post) was designed primarily with logistics in mind. Having a physically separated “hatchery” (spawning block) and “command center” (storage block) allows for you to place the central dropoff point for resources closer to the ideal location that minimizes total path length to nearby sources without being constrained by the full bulk of the base. This design served this purpose well, but it suffered from two key defensive flaws: the tower spread reduces total tower damage at siege points, and the spawning rate can be limited by the hatchery link bandwidth.

Enter bunkers. Bunker assets have been sitting in the AI for a long time, but living next to everyone’s friendly neighborhood tiger forced me to prioritize their development one he figured out how to exploit the flaws of my previous layout. The final design went through a lot of iterations, but I’m quite happy with how it turned out. Here’s an annotated image of a fully-developed base:

Each bunker has three permanent attendants: a manager and two queens. Managers are stationary 16-CARRY 0-MOVE creeps that sit in the center of each bunker, connecting the storage, terminal, central link, and RCL8 structures. Queens are general-purpose base attendants which fill and empty structures requesting any type of resource.

Managers are relatively unchanged in bunker colonies and are run by the same overlord as in the classic layout. The most notable difference is that managers for RCL8 bunkers are immobile (a design choice enabled by some improvements to my creep spawning code), spending their entire life at the central “anchor” tile of the bunker. If there are ramparts within range 3 of the anchor below their target hits, the manager will be spawned with 32 WORK parts and will fortify the ramparts when it is idling.

Although they share the same role name as the hatchery attendants in the classic layout, queens are run by a separate overlord in bunker-type colonies, which features a large number of hard-coded optimizations specific to the bunker layout. Each “quadrant” (group of contiguous buildings) in the bunker has a hard-coded fill order (illustrated in the above image) to minimize walking distance, and each queen gets assigned two quadrants and a “battery” (the top and bottom containers in the bunker, which serve as an energy buffer). To further reduce the CPU cost, rather than executing the fill logic after every transfer, queens are assigned a single chained task object which represents an entire “manifest” of supply operations which can be done with the creep’s carry capacity. (The chained task also sets the nextPos property of each subtask to ensure that the queen promptly moves to her next destination so no ticks are wasted idling between tasks.)

The task-chaining logic and the generality of the logistics system makes handling requests for multiple resources in a single carry quite straightforward. So in bunker-type colonies, queens are double-purposed as lab attendants (a job handled by the manager in the classic layout). A nice feature of my bunker layout is that every spawn has a lab adjacent to it, meaning that creeps can be boosted while they are still spawning! This helps to reduce congestion within the base and maximizes the boosted lifetime of the creeps.

Another quirk of my new layout is that at RCL8, only 51 of the available 60 extensions are built in the main bunker. Having only 51 extensions significantly improves the compactness of the design while still allowing for one exit on each side. The remaining extensions will be placed next to “dropoff” links in the room (links not claimed by a miningSite or upgradeSite) and will be filled by idle transporters. In the event of a siege where the links and external extensions could easily be destroyed, 51 extensions poses almost no limitation to the types of defensive creeps which can be spawned, as the colony could still spawn the most expensive healer creeps with 38-HEAL, 12-MOVE bodies.

Traffic management

If bunkers’ greatest strength is the high tower damage resulting from their compactness, their greatest weakness is the congestion resulting from their compactness. Making bunkers work required some massive improvement to my traffic management code and resulted in a completely new movement library. (Previously, I used Traveler; my new library uses some of the same code under the hood but adds a number of new features and integrates more tightly with the Overmind framework.)

All creeps in my AI now have a role-dependent movement priority, and they will push slower or blocking creeps with lesser move priority out of their way. In general, this results in the two creeps switching locations, but if the blocking creep is performing a task (such as a worker blocking a pathway while sitting in the base fortifying a rampart), it will try to move to a position that is out of the way and still in range of its task target. This allows for some pretty cool behavior like this:

https://gfycat.com/rigidfirsthandasiaticmouflon

Even if creeps are able to fluidly move past each other, another complication with bunkers is that groups of creeps clogging the alleyways can result in baby creeps being unable to exit their spawns. This is a particularly pronounced issue with my design, as each spawn has only two exit tiles. To solve this, I implemented a vacatePos method which recursively pushes creeps down alleyways and blocks further movement attempts for that tick to vacate the target position.