And i just realized that simplest way to look at the code is to look at the prototype, and not trying to find instance
RoomPosition.prototype.findInRange
And i just realized that simplest way to look at the code is to look at the prototype, and not trying to find instance
RoomPosition.prototype.findInRange
there is also game const in case it changes in future
CREEP_SPAWN_TIME: 3
I think first thing to do would be check if it's a problem at all, you can do that with a profiler: https://github.com/gdborton/screeps-profiler/ , premature optimization and optimization without profiling are not good most of the time.
Also the profiler can profile specified function if you pass functionFilter to it, so you can profile both variants with simple for i in range something test loop (and you will probably have to enable profiler only at the end of the main loop and do test for loop after that, so game functions monkey-patched only for testing for loop).
And also for most public game functions you can look at their code by inserting function name in console and pressing enter, it is not always helpful but in case of RoomPosition.prototype.findInRange you can see in code that it does call room.find
function (type, range, opts) {
var room = register.rooms[this.roomName];
if (!room) {
throw new Error(`Could not access room ${ this.roomName }`);
}
opts = _.clone(opts || {});
var objects = [],
result = [];
if (_.isNumber(type)) {
objects = room.find(type, opts);
}
if (_.isArray(type)) {
objects = opts.filter ? _.filter(type, opts.filter) : type;
}
objects.forEach(i => {
if (this.inRangeTo(i, range)) {
result.push(i);
}
});
return result;
}
The punishment for respawn is too harsh. Respawn throws whatever you have in garbage can, meaning you wasted you time and money on absolutely nothing. Right now respawn is like you play some MMORPG (lineage 2, wow, whatever is popular these days) and you get to whatever level you get, you die, and you loose all your items and skills and the only thing left is useless level number. I don't feel like doing exact same things over again, even when it means sitting 2 weeks and watching creeps do their job.
I'm surrounded by guys with 2 towers, i can't kill them and have no exit to area center or borders or any room to seize at glc3. Whatever i achieved is useless, i don't feel like playing anymore, and i'm simply waiting for my subscription to expire or my neighbours to kill me or both. I admit, i've fucked up, i shoud have killed everyfuckin newbie i could before it's too late no matter how disappointed they gonna be in game. Or chosen different room at the beginning, steep learning curve makes you not able to make informed decision about such things until it's too late, imho.
Please don't let retards like me to fuckup themselfs in future and dissallow spawning next to players (diagonals and no-exits don't count) at least at newbie areas.
PS: sorry for being emo about it.
TOS prohibit you from registering new account to play game, it says nothing about registering new account and never spawning. If you can (have money to) support developers and the thing you want is supporting developers and not lobbying your interests or pay2win, then everybody will be glad if you create as many new account as you want, pay subscription and never spawn on them.
I was not subscribed at the time, and at the time there were no status page for screeps, but when i found out about the game (few days before steam release) on multiple occasions i found messages from players saying that tick duration is 1-2 seconds. If that (2.5s) is the case, i'm sorry for misinformation.
I know that, i'm not suggesting that, i'm suggesting pay for fixed (and equal for everyone) amount of ticks model. You pay for N ticks and if tick duration is 3 real world seconds your script is running with whatever CPU restrictions (equal or based on GLC) you have for 3*N real world seconds (not CPU seconds), if tick duration is 10 real world seconds your script is running with whatever CPU restrictions (equal or based on GLC) you have for 10*N real world seconds (not CPU seconds).
If tick duration growth is inevitable and player base is willing to pay for current model, the other suggestion that i have is balancing out energy (and probably minerals too) according to tick duration, enlarge the amount of energy sources have, amount of energy per WORK part harvested e.t.c. so amount of proggres per real world time stays same with tick duration growth.
The change that kinda bothers me is the fact that ever since steam release avg tick duration was climbing up and changed from ~1.5 (UPD: players in comments say it was 2.5 during steam release, but no mater time frame it is obviously growing with the amount of players in game) to >3 (3.13 last week, 3.51 last 24 hours, 3.78 last 10 minutes atm of post creation) which may seem like not much but if you consider the 24/7 fact then you kinda realize that it means you progress >2 times slower already, you wait 2 times more for things to happen, you harvest 2 times less energy per real world day, you upgrade you controller to next RCL 2 times longer, and basically you buy less progress for the same subscription price. The game was slow paced, and now it's 2 times slower then slow paced. The CPU system imho already seams kinda not 100% fair since the amount of goods you receive for the price differs based on your GCL (which mostly, differs with real world expirience, buying VPS for instance), but at least it encourages new players to write better code. But, again, imho max room count is big enough reward for GLC and trading (equally limited for all players) CPU time in the begging for efficiency (billion little checks for range to everything? billion little creeeps that chain from source to controller in pre-Link room? and other crazy CPU eating creative stuff) and profiling\optimizing as you progress seam like fun too. If ~constant tick duration is not possible (which it seam like), wouldn't it be fair for players be billed based on amount of ticks code gets executed? If not, would you, player, change your mind if in a week it will grow to 5s per tick? 20s per tick in a month?
UPD:
If tick duration growth is inevitable and player base is willing to pay for current model, the other suggestion that i have is balancing out energy (and probably minerals too) according to tick duration, enlarge the amount of energy sources have, amount of energy per WORK part harvested e.t.c. so amount of proggres per real world time stays same with tick duration growth.
I am, i use it too since there is nothing better, but it has disadvantages:
For notifications like 'Your creep Creep in room Room is under attack!' and other ones that have exact room and time location, it would be helpful to have link to exact tick in room replay because if something unexpected happens you go to replay and see what was that anyway. At some point replay will expire, but from my experience it does not matter since most of the times i read notification at least once a day.
Some other suggestions:
Game.creeps
? Seems like bad code organization anyway.Spawning copy of soon-to-be-dead or some other creeps?
Not doing it, but someone might.
infinite loop? did you mean number-- in both for loops?
for (;number > 0; number++)