Rastikko / screeps-lodash

Lodash based screeps codebase
2 stars 1 forks source link

Storage #3

Closed Kill4Free closed 8 years ago

Kill4Free commented 8 years ago

I had the following idea: If a carrier carries energy but no one needs it, we could store it inside a storage. This way you can set a container near the upgrader to minimize the carrier movement and the upgraders downtime.

Therefor the pickup-energy should be edited to only pickup and a store-energy command should be added as last for carriers. The other nice thing you can use this energy if you're starting a new room or you're out of energy.

What do you think?

PS: TodoList for next version: :+1: or :-1: ?

Rastikko commented 8 years ago

I like it :+1: , we would need to tweak a little the transfer command. Right now is only been ignore if the room is spamming (And actually this reminds me I need to add this memory in the command-spawn). To include other things like, towers without energy (specially if you under attack).

After that I wanted to improve the way we find storage to be more efficient. I had a method findClosestNotEmpty that I've copy from someone else. I was hopping to be able to tweak it to also allow search this that are empty. It could look like this:

creep.findClosest({
  structures: [STRUCTURE_STORAGE, STRUCTURE_SPAWN,...],
  empty: true,
  droppedEnergy: false, // include dropped energy to search
  energy: 20 // energy necesary to consider is empty
});

This way we will be able to add new drop items with the same function.

Here is an example where I use the findClosestNonEmpty: https://github.com/Rastikko/screeps-lodash/blob/0120fb42eb07545bc96b7342b31247ff0358d082/src/_creep-command-pickup.js#L3-L7

Rastikko commented 8 years ago

Did it in https://github.com/Rastikko/screeps-lodash/pull/8