screeps icon indicating copy to clipboard operation
screeps copied to clipboard

How to deal with ruins

Open FormatToday opened this issue 4 years ago • 1 comments

I'm a beginner, and I found that there are some ruins in my room that are not handled well. So may I ask which code is responsible for the ruins.

FormatToday avatar May 14 '20 01:05 FormatToday

Ruins are not yet handled. A room has two stages:

  • Before storage where creeps are moving more freely, mostly defined in prototype_creep_startup_tasks. It uses getEnergy https://github.com/TooAngel/screeps/blob/2c325007216aa544284f3bb30ea808c49d609fc1/src/prototype_creep_resources.js#L652 to decide where to get energy from. I would add something like getEnergyFromRuins, searching for ruins, move to them, pickup, like getDroppedEnergy. The method should consider if it makes sense to move there (low resources, low time to decay => maybe not)

  • With storage: Most of the creeps move on the precalculated paths. So ruins should be mostly on the path itself and can be picked up by the next creep passing by (no need to move there). pickupEnergy https://github.com/TooAngel/screeps/blob/2c325007216aa544284f3bb30ea808c49d609fc1/src/prototype_creep_resources.js#L347 is used for that, I guess withdrawContainers would be similar.

So if you like have a look, let's discuss here or send a Pull Request.

TooAngel avatar May 14 '20 08:05 TooAngel