pub const INVADERS_ENERGY_GOAL: u32 = 100_000;
Expand description

Base value for calculating the energy harvest amount that will trigger invader spawns.

Calculated energy to be harvested in a given room until invader creeps spawn falls randomly in a range from 70% to 130% of this value, then has a chance to have a modifier applied according to the formula (source):

let invaderGoal = Math.floor(INVADERS_ENERGY_GOAL * (Math.random()*0.6 + 0.7));
if(Math.random() < 0.1) {
    invaderGoal *= Math.floor( Math.random() > 0.5 ? 2 : 0.5 );
}

Note that due to the use of Math.floor, the 0.5 will become a multiplier of 0, which won’t be used; this bug is reported here