So, I scrapped most of the tutorial code and settled on the following rough framework: My goal is to create an entirely autonomous AI that plans and constructs its own room, eventually expanding into other rooms, without direct intervention or guidance from me. This reaches its limits fairly quickly, as the minions that you want to spawn will vary depending on on your room control level, available energy, and other situational factors. The tutorial effectively brute-forces it, creating a spawn queue (to generate a certain number of minions) and assigning them simple behaviors that ensure that miners do mining, builders do building, etc. There are any number of ways to attack this problem. So we have our primary Source a primary Sink (the controller) and secondary Sinks (minions and infrastructure). Maintaining this infrastructure involves the initial energy cost of construction, and then an ongoing cost of repairs. A stationary Miner and a mobile Hauler are more efficient working together than two mobile Miners. Then a dedicated Hauler minion with CARRY and MOVE parts can collect the energy from the container and move it elsewhere. This Miner can harvest a Source at its maximum rate, and, if it is sitting on a Container, will automatically drop its harvested energy in the container. At RCL 2, we can create a single dedicated Miner minion with 5x WORK and 1x MOVE parts. The next logical step is setting up a container network. Roads reduce the amount of time taken in transit (significantly, in the case of swamps). Scaling up by adding additional minions is expensive, but there are other ways to reduce the time cost. That time cost adds up to “time not spent harvesting energy,” which is source energy wasted. We’ll have additional time costs to resupply the Spawn with enough energy to create more minions. We’ll have energy costs in creating that minion initially, and time costs in the minion’s movement from the source to the controller and back. InfrastructureĪt an early level, this might be a simple minion that collects energy, moves to the controller, and deposits it. So the bottleneck will be infrastructure: moving energy from the sources to the controller.
The room controller has no upgrade cap until RCL 8, which is far enough away that we can ignore that for now. This is not too difficult, and can be met with a single minion with 5 WORK parts, starting at RCL 2. As noted above, 10 Energy/tick will exactly match the Source’s maximum output rate. The first step here is maximizing our inputs. Our main objective is upgrading the room controller, so we want to maximize our output (energy to the room controller). This includes Roads (to increase throughput), Extensions (to increase minion effectiveness), and Containers (to enable specialization). Once our Sources are fully tapped, we can optimize the transfer of energy from the Sources to the Controller by Building Infrastructure. If we are pulling 10 Energy/tick out of each Source, we’ve maximized our resource usage. There are a fixed number of Sources in a room, and they resupply at a fixed interval. In order to maximize that surplus, we need to Maximize our Inputs. This unlocks additional Structures (especially Containers and Extensions) that will be useful for improving energy throughput, and it’s also representative of the surplus energy our production process is generating. So, at the initial stage, the main objective is Upgrading the Room Controller. I decided to focus on economic growth before defense. In the rest of the article, I’ll assume you’re familiar with the terminology from either the tutorial or the game documentation. This gave me enough experience to draw some patterns. I began by playing through the tutorial and improving the sample code, until I reached RCL (room control level) 4. Your available CPU is limited, so you have to write an AI that is both powerful and efficient. Screeps is an MMORTS (massively multiplayer online real-time strategy game) with a unique twist: instead of controlling your units directly, you write code in Javascript to build and manage them.