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 oen 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. 1  distance transform
  2. Select Starting Position: Choose an open area you think the best for your base. I prefer close to both the controller and energy sources, especially proximity to the controller. But remember, everything is up to you! 2  start 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! 3  core structures
  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 considered properly that every position should be within range 3 to the controller. Don’t make a mistake like me! 4  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. 5  flood fill
  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.” 6  grid
  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 stamp for labs 7  labs
  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. 8  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 mistake I mentioned earlier and made the controller upgrade area to be closer to controller. The minimum cut code is available here. 10  roads to ramparts
  10. Tower Placement: Position towers to maximize their coverage. Personally, I prioritize maximizing the minimum damage of towers over base boundaries. 11  towers
  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 changed lab position a bit and marked them as green square. 12  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 a green square, and towers with a red square. 13  example(1) 14  example(2) 15  example(3) 16  example(4) 17  example(5) Automating base planning streamlines your development process and lays a solid foundation for your Screeps bot to thrive.

Updated:

Leave a comment