You could make 2 creeps instead (both with 6 carry parts and one move part) and pass the energy between them. This way the energy would not evaporate.
Posts made by _Zinal
-
RE: Message passing between players
-
Room.energyAvailable does not count Storage structure
The Room.energyAvailable property does not take into account the Storage structures store.energy property (Structure.store.energy) nor the Room.energyCapacityAvailable.
-
Mailing out changelogs
I would like to request that the changelogs or atleast an update message be mailed out everytime the API changes. There's been a few updates that I didn't notice until a few days later (When my script fails to run due to said changes). Would it be possible?
-
RE: FIND_MY_STRUCTURES and walls
Well, the interesting part about that is that it still sets the my and owner parameters correctly. If it does that, why not allow it in the FIND_MY_STRUCTURES aswell?
-
FIND_MY_STRUCTURES and walls
Walls cannot be found with the FIND_MY_STRUCTURES parameter
-
RE: Recolour Individual Creeps
I second this! coloring individual creeps would be very, very useful!
-
RE: Strange error when executing successful command from console.
My guess is that the modules and the console is run on separate instances.
As far as I can tell, the console is running on the global namespace while the main module (and the other modules you require('') from the main module) are running on another instance. Which means that whatever module (in this case builder) you load from the main module will not affect the console. -
RE: [QUESTION] Math equation for distance & energy on the ground
Sorry about the code looking wierd.. for some reason Markdown isn't working properly when I try it
-
[QUESTION] Math equation for distance & energy on the ground
Hello everyone!
First, let me just say this: I'm no math genius!I've been trying to make a mathematical equation for a while now but I'm kinda stuck..
Basically, what I want is an equation that takes into account the distance and the amount of energy on the ground (DROPPED_ENERGY).Why?
In my 'base' I have two essential creep-roles: Miners and Collectors.The miners just stand near the active sources and mine, dropping all the energy to the ground instantly.
The second role; Collectors; are a bit more complicated.
They grab the energy from the ground and transports them to either a spawn, an extension or the the controller (Links are not accounted for yet)
Currently, I'm using the Creep.pos.findClosest function to find the nearest dropped energy, which has been working great so far but I ran into a problem.The findClosest function works great if you only have one source in your room. I currently have 2 miners on two different sources.
One of the sources is very close to the spawn and the other is a little bit further away.The problem right now is that my Collectors only target the source near the spawn, since that is the closest (and will always be the closest).
So, I was thinking: Is there a way to take the amount of energy on the ground into account when calculating the distance to the dropped energy?I currently have this code:
var _roomData = {}; Room.prototype.xFind = function(type, filter, sorter, opts) { if(_roomData[type] == undefined) { _roomData[type] = this.find(type, opts); } var back = _roomData[type]; if(filter != undefined) { back = _.filter(back, filter); } if(sorter != undefined) { back.sort(sorter); } return back; };
Which is really just a function to cache the results of all the find-function results. The interesting part here is the sorter argument.
The sorter argument is a function that sorts the results if provided. The function takes two arguments: Object A and Object B.
I've used a sorter function which looks like this to make my own "findClosest" function:
function(a, b) { var ar = creep.pos.getRangeTo(a); var br = creep.pos.getRangeTo(b); if(ar == br) return 0; return (ar > br ? 1 : -1); }
This however, only takes the range into account, not the dropped energy (a and b are in this case Energy objects).
Does anyone have an idea on how to make an equation that takes into account the amount of energy in a & b?For example:
Energy a is 11 tiles away (ar = 11) and has 500 energy (a.energy = 500)
Energy b is 16 tiles away (br = 16) and has 2500 energy (b.energy = 2500).Now, b is not too far away for a, but my current function will always return a (since it's closer)..
Anyone have any ideas? I really, really suck at math
-
RE: Building structures
Another way to save CPU usage is to store the values of the FIND functions into a temporary module. I went from 60~70% CPU usage to about 20~30% with this code:
```
var roomData = {};
Room.prototype.xFind = function(type, filter, sorter)
{
if(roomData[type] == undefined)
_roomData[type] = this.find(type);var back = _roomData[type]; if(filter != undefined) { back = _.filter(back, filter); } if(sorter != undefined) { back.sort(sorter); } return back;
}
```