bencbartlett/Overmind

Manager trapped outside of base's core.

GuguKatze opened this issue · 0 comments

Managers spawned by the wrong spawn can't reach its intended position.

See history tick: https://screeps.com/a/#!/history/shard2/E41S51?t=14340988
(The right-most spawn is the only active one and the manager is spawned by it the next tick.)

This is caused by Overmind not being able to utilize "isActive() !== true" spawns to do downgraded RCL. It implies that we still have more than 1 spawn because if we only had one it would either be the right one, spawning the manager on the right tile or it would be the wrong one but there would be a path towards the intended manager position as the "right" spawn would be missing in this case. While .destroy()-ing all inactive spawns would work I don't think it's the right thing to do.

Proposed solution: If the manager can't find a path to its intended position then set some boolEnsurePathToCenter variable.

Compute the number of towers in the room. If it's above the RCLs "tower capacity" (numberOfTowers > CONTROLLER_STRUCTURES.tower[RCL]) then call .destroy() on one of the innermost towers. One of the remaining towers will take over.

If the number of towers is <= the RCLs capacity (we are in big trouble anyway ... or we are at RCL8 with all the core building in place - otherwise there would be a path - but spawned the manager via the wrong spawn for some reason.) then call .destroy() on the PowerSpawn. (There would be a path in the first place if it didn't exist.)

Towers are the cheapest building to replace but maybe go for the PowerSpawn right away. It's very expensive to rebuild but less complicated and missing a tower (even for 100 ticks) after re-gaining an RCL could be critical. Missing a PowerSpawn on the other hand wouldn't matter at all. (Unfortunately, we can not rely on the order towers become inactive on controller downgrades when building them as losing one during a fight will mess with the order anyway.)