2 minute read

Why Base Planning?

Planning the layout of your base in Screeps might seem unusual at first, but it’s a crucial step in automating your bot. It’s also one of the most challenging tasks to tackle on your own from scratch. While you don’t necessarily need to fully understand the algorithms involved, you should at least know how to utilize them effectively. So, here’s a step-by-step guide on how I automate my base planning. Let’s dive into it.

The Process

  1. Utilize Distance Transform
    Start by employing the distance transform algorithm to identify open spaces in the room. Typically, my bot requires a 5x5 square to begin, so I target positions with a distance of 3 or larger. Some bots, especially those employing bunker-style base planners, may require squares larger than 10x10. Plan ahead for the desired size of your base. The distance transform code is available here.

    Screenshot: Distance transform result

  2. Select Starting Position
    Choose an open area you think is best for your base. I prefer locations close to both the controller and energy sources, especially proximity to the controller. But remember, everything is up to you!

    Screenshot: Selected starting position

  3. Place Core Structures
    Begin by placing core structures such as spawn, storage, and terminal. I surround the starting position with core structures using a 5x5 stamp for efficiency. Some bots utilize a stamp called “fast filler” to quickly fill extensions. The choice of design is up to you!

    Screenshot: Core structure layout

  4. Designate Controller Upgrade Area
    Allocate a 3x3 area near the core structures for upgrading the controller. I made a mistake in the screenshot below — I didn’t properly ensure that every position was within range 3 of the controller. Don’t make the same mistake!

    Screenshot: Controller upgrade area

  5. Implement Floodfill Algorithm
    Utilize the floodfill algorithm to categorize tiles by their accessibility. Lower numbers indicate proximity to core structures. The floodfill code is available here.

    Screenshot: Floodfill result

  6. Allocate Tile Usage
    Assign tiles for essential structures such as extensions, labs, towers, factory, nuker, and observer. I personally prefer a grid layout similar to the “commie bot.”

    Screenshot: Grid layout

  7. Position Labs
    Identify 10 suitable tiles meeting specific criteria, ensuring that there are two source labs within range 2 of every other lab. If it seems too complicated, it’s fine to use a predefined lab stamp.

    Screenshot: Lab placement

  8. Establish Infrastructure
    Lay down roads from storage to energy sources and minerals. Place a container and a link at each source, and a container and an extractor at the mineral.

    Screenshot: Roads to resources

  9. Optimize Ramparts
    Utilize the minimum cut algorithm to determine optimal rampart positions, then connect them with roads. At this stage, I noticed my earlier mistake and moved the controller upgrade area closer to the controller. The minimum cut code is available here.

    Screenshot: Roads to ramparts

  10. Tower Placement
    Position towers to maximize their coverage. Personally, I prioritize maximizing the minimum damage of towers over base boundaries.

    Screenshot: Tower placement

  11. Place Additional Structures
    Situate the factory, nuker, observer, and extensions. Placement for the observer is less critical, so anywhere works. At this stage, I also adjusted the lab positions slightly and marked them as green squares.

    Screenshot: Nuker, factory, observer, extensions

Examples and Visuals

Here are some examples created by my bot. The upgrade area is marked with a yellow square, labs with green squares, and towers with red squares.

Screenshot: Example base layout 1

Screenshot: Example base layout 2

Screenshot: Example base layout 3

Screenshot: Example base layout 4

Screenshot: Example base layout 5


Automating base planning streamlines your development process and lays a solid foundation for your Screeps bot to thrive.

Updated:

Leave a comment