hivemind
hivemind copied to clipboard
Better recover from downgrades
So something I found out recently, if the controller has downgraded, then room.energyAvailable
might be greater than room.energyCapacityAvailable
so your spawning stops due to if (cost > room.energyAvailable)
in spawn-manager
.
Quick fix possibly to do if (cost > room.energyAvailable || cost > room.energyCapacityAvailable)
Which also means that a check for isOperational
could be added to Room.prototype.getEnergyStructures
so the inactive extensions are not included when trying to spawn.
An additional could be getCreepBody
in harvester and transporter spawn-role could check if there is a harvester or transporter and if not spawn with Math.min(room.energyAvailable, room.energyCapacityAvailable * 0.9);
So what you're saying is, room.energyAvailabe says there is a certain amount of energy available, but tryiing to use that much energy to spawn fails? That's not great... And it would cause problems for any spawn role, not just harvesters and transporters, since most work with a limit of Math.max(room.energyCapacityAvailable * 0.9, room.energyAvailable)
or something similar. We'd have to wrap all of these into a Math.min(room.energyCapacityAvailable, ...)
to fix this, which is not great, but I can't think of anything better right now.
The change to spawn-manager doesn't help since it will just prevent spawning, as it does currently. But the isOperational
check makes send, that was still missing for extensions that were not part of a bay :+1:
Yes. It happens when you have filled an extension and the extension is no longer usable due to a controller downgrade, then the energy in the extension is included in energyAvailable
but not in energyCapacityAvailable
.
I don't see a good fix either and you are right that it does affect all spawning. I was highlighting harvesters and transporters as if spawning for those is blocked you can't pull out of the downgrade spiral.
Could be something as simple as working out how much energy to provide the body-builder? e.g.
let energyLimit: number;
if (option.force) {
energyLimit = 250;
} else if (!room.creepsByRole.transporter) {
energyLimit = Math.min(room.energyAvailable, room.energyCapacityAvailable * 0.9);
} else {
energyLimit = Math.max(room.energyCapacityAvailable * 0.9, room.energyAvailable);
}