-
Notifications
You must be signed in to change notification settings - Fork 55
Room Management
When adding new features that consume energy it is important to restrict them from occurring unless the economy can handle it.
Quorum defines multiple economic states which can be viewed in the table below. These are integers, such that ECONOMY_CRASHED < ECONOMY_FALTERING < ECONOMY_DEVELOPING < ECONOMY_STABLE < ECONOMY_SURPLUS < ECONOMY_BURSTING
. The current state of a room can be retrieved using Room.prototype.getEconomyLevel
.
Economy states are based off of how much energy is in storage. For rooms that do not have a storage the economy is locked at ECONOMY_STABLE
.
Level | Energy Levels (at PRL8) | Notes |
---|---|---|
ECONOMY_CRASHED | < 15,000 | Focus on energy, nothing else |
ECONOMY_FALTERING | < 280,000 | Only spend energy if it will help the room stabilize |
ECONOMY_DEVELOPING | < 300,000 | Perform any required room functions but nothing beyond that |
ECONOMY_STABLE | < 320,000 | Allow larger energy sinks, such as controller upgrades |
ECONOMY_SURPLUS | >= 320,000 | Increase amount spent on energy sinks to try and lower level |
ECONOMY_BURSTING | >= 320,000 (and storage >90% full) | Spend as much energy as possible |
Quorum also has a system for defining what actions take place at each of those levels. Inside src\extends\room\economy.js
a simple object exists which defines what room features can be enabled at each economy level-
const economySettings = {
'SUPPLY_TERMINAL': ECONOMY_FALTERING,
'EXPAND_FROM': ECONOMY_DEVELOPING,
'WALLBUILDERS': ECONOMY_DEVELOPING,
'BUILD_STRUCTURES': ECONOMY_DEVELOPING,
'EXTRACT_MINERALS': ECONOMY_STABLE,
'UPGRADE_CONTROLLERS': ECONOMY_STABLE,
'EXTRA_UPGRADERS': ECONOMY_SURPLUS,
'EXTRA_WALLBUILDERS': ECONOMY_SURPLUS,
'MORE_EXTRA_UPGRADERS': ECONOMY_BURSTING
}
The Room.prototype.isEconomyCapable
takes the different economy settings and returns whether the economy is capable of supporting that feature.
Defining when a room should attempt different actions is just as important as defining if that room can afford them. There are three main methods in Quorum for defining a room's capabilities.
The Practical Room Level (PRL) is calculated by comparing the built structures against the limits at each Room Control Level. For instance, a room at RCL8 that had all of its extensions and three towers but no storage would have a PRL of three.
Just like with the economy controls there is a system that defines what objects will run at what PRL, this time defined in src\extends\room\control.js
. This object defines settings at each PRL, and those settings can be anything (boolean, integer, string, object). Each subsequent level inherits the settings from the level before it.
Room.prototype.getRoomSetting()
will return the specific settings- for example, room.getRoomSetting('UPGRADERS_QUANTITY')
will return 5 starting at PRL1, 3 starting at PRL6, and 1 at PRL8.
For some capabilities it makes more sense to directly check the room. As one example the mining
program specifically looks for room storage when deciding whether to spawn haulers
or not.
There are some settings that should always check the room level. It would not make sense to have more than 15W on an Upgrader
at RCL8 since that is the max amount that can be upgraded for tick, so a check against that (as well as a hard limit on the Upgrader
quantity) is in place.