Difference between revisions of "Automatic base building"

From Screeps Wiki
Jump to navigation Jump to search
Line 10: Line 10:
 
=== Bunker ===
 
=== Bunker ===
   
[[File:BunkerExample.png | left | 200px|An example of a bunker-style base]]The easiest by far is to have a pre-defined 'bunker' containing all structures you are intent on using and simply finding an open area to place it. The 'center' of the bunker ancor and from there you can generate the structures of your pre-determined bunker based on their relative position to the ancor. As long as the space is there, there should be no conflicts in the generation.
+
[[File:BunkerExample.png | left | 200px|An example of a bunker-style base]]The easiest by far is to have a pre-defined 'bunker' containing all structures you are intent on using and simply finding an open area to place it. The 'center' of the bunker anchor and from there you can generate the structures of your pre-determined bunker based on their relative position to the anchor. As long as the space is there, there should be no conflicts in the generation.
   
<br><br><br><br><br><br><br><br><br>
+
<br><br><br><br><br><br><br>
   
=== Stamp/Tilesets ===
+
=== Stamp/Tile-sets ===
   
Normally using a core tile/stamp, you can then determine locations for other pre-defined tilesets/stamps to be placed around your ancor dependent on the terrain in the room.
+
Normally using a core tile/stamp, you can then determine locations for other pre-defined tile-sets/stamps to be placed around your anchor dependent on the terrain in the room.
   
 
=== Dynamic/Pattern Generation ===
 
=== Dynamic/Pattern Generation ===
Line 27: Line 27:
   
 
There are several useful algorithms to take into consideration when automatically building your base.
 
There are several useful algorithms to take into consideration when automatically building your base.
 
 
 
=== Distance-Transform ===
 
=== Distance-Transform ===
   
 
[[File:Redcirclegen.png|left|200px|An Example of Distance-Transformation on a room with roomVisuals]]Using the Screep's terrain, you can use [https://en.wikipedia.org/wiki/Distance_transform Distance Transformation] to have natural walls be barrier pixels and swamps/plains to be allowed. Using this, you can then create a matrix/object/array of all positions with a score of how much open space is available around a given roomPosition. This is direly useful to know how much you can fit in an area, without having user input.
 
[[File:Redcirclegen.png|left|200px|An Example of Distance-Transformation on a room with roomVisuals]]Using the Screep's terrain, you can use [https://en.wikipedia.org/wiki/Distance_transform Distance Transformation] to have natural walls be barrier pixels and swamps/plains to be allowed. Using this, you can then create a matrix/object/array of all positions with a score of how much open space is available around a given roomPosition. This is direly useful to know how much you can fit in an area, without having user input.
   
<br><br><br><br><br><br><br>
+
<br><br><br><br><br><br>
   
 
=== Flood Fill ===
 
=== Flood Fill ===
Line 39: Line 37:
 
[[file:PrototypeFloodFill.png|left|200px|An example of a flood-fill, filling the 'outside' of a predefined base area.]][https://en.wikipedia.org/wiki/Flood_fill Flood Fill] is useful for defining or testing areas to make sure they are secure (like walls around a base) or defining areas into groups. Filling an area and gathering room positions allows you to use these positions later, for whatever purpose you see fit.
 
[[file:PrototypeFloodFill.png|left|200px|An example of a flood-fill, filling the 'outside' of a predefined base area.]][https://en.wikipedia.org/wiki/Flood_fill Flood Fill] is useful for defining or testing areas to make sure they are secure (like walls around a base) or defining areas into groups. Filling an area and gathering room positions allows you to use these positions later, for whatever purpose you see fit.
   
<br><br><br><br><br><br><br>
+
<br><br><br><br><br>
   
 
=== Minimum Cut ===
 
=== Minimum Cut ===

Revision as of 16:15, 24 October 2020


Automatic base building is the process of finding, claiming and, building up a claimed room without using the UI and direct user input. For many fully a fully automatic bot is the end-goal and automatic base building is a large step.


Types

There's a few types of automatic bases, depending on method used.

Bunker

An example of a bunker-style base

The easiest by far is to have a pre-defined 'bunker' containing all structures you are intent on using and simply finding an open area to place it. The 'center' of the bunker anchor and from there you can generate the structures of your pre-determined bunker based on their relative position to the anchor. As long as the space is there, there should be no conflicts in the generation.








Stamp/Tile-sets

Normally using a core tile/stamp, you can then determine locations for other pre-defined tile-sets/stamps to be placed around your anchor dependent on the terrain in the room.

Dynamic/Pattern Generation

Using a given open area, you can generate a structure or set of structures grouped together based on some basic rules.


Useful Algorithms

There are several useful algorithms to take into consideration when automatically building your base.

Distance-Transform

An Example of Distance-Transformation on a room with roomVisuals

Using the Screep's terrain, you can use Distance Transformation to have natural walls be barrier pixels and swamps/plains to be allowed. Using this, you can then create a matrix/object/array of all positions with a score of how much open space is available around a given roomPosition. This is direly useful to know how much you can fit in an area, without having user input.







Flood Fill

An example of a flood-fill, filling the 'outside' of a predefined base area.

Flood Fill is useful for defining or testing areas to make sure they are secure (like walls around a base) or defining areas into groups. Filling an area and gathering room positions allows you to use these positions later, for whatever purpose you see fit.






Minimum Cut

A base map for minCut, yellow is walkable, purple is exit, green is protected (can't cut)
Result of the previous base map after cut

Minimum Cut is useful for rampart / wall placement.