It is out of our control to save data consistently. The only thing we can do is to use old "architecture" cause it is not as buggy as new one.
Actium
@Actium
Posts made by Actium
-
RE: creepCounter problemposted in Help
-
RE: creepCounter problemposted in Help
It does not work because nodes the game world is simulated on do not see the same data at the same time. In simple words, data are inconsistent.
-
RE: Ticks Usedposted in General Discussion
Optimized a bit:
average CPU consumption: 11.64
average creep count: 55.88
number of rooms: 5
CPU limit: 20 -
CPU limitposted in Help
Can somebody explain me why does a script containing the single line
console.log(Game.cpuLimit);
output the following:[10:45:31 AM] 261
[10:45:44 AM] 281 // ok, +20 (CPU limit is set to 20)
[10:46:08 AM] 279 // strange, -2
[10:46:15 AM] 296 // basically, ok, +17
[10:46:27 AM] 313
[10:46:31 AM] 328
[10:46:39 AM] 289 // very strange, -39
[10:46:44 AM] 308
[10:46:56 AM] 325
[10:47:01 AM] 325 // strange, 0
[10:47:12 AM] 341
[10:47:25 AM] 360
[10:47:37 AM] 380
[10:47:48 AM] 399
[10:48:01 AM] 418
[10:48:13 AM] 418 // 0 again -
Ticks get longer and longer and longerposted in General Discussion
Yesterday the length of a tick was about 3 seconds. At the moment one tick is simulated in 10 seconds. Where the world is heading...
-
RE: Ticks Usedposted in General Discussion
average CPU consumption: 14.77
average creep count: 45.24
number of rooms: 4
CPU limit: 20I want to optimize my code but do not have enough time

-
RE: What is a good way to build proper defense at start?posted in General Discussion
Having 2 energy sources in the room you can upgrade the controller up to level 4 until walls down.
-
RE: How are we upgrading our creeps?posted in General Discussion
You can predefine levels for every role as follows:
var carrier_levels = [ { cost: 100, body: [ CARRY, MOVE ] }, { cost: 200, body: [ CARRY, MOVE, CARRY, MOVE ] } ];
Then select most appropriate level for certain conditions.
-
Profilingposted in General Discussion
Disclaimer: I did not program with javascript until started playing screeps.
Recently my script has been terminated due to CPU limit. In order to deal with this issue I wrote the following code:
var enable_profiling = true; if (enable_profiling) { Memory.p = Memory.p || {}; var wrap = function(c, n) { var p = Memory.p[n] || { usage: 0, count: 0 }; Memory.p[n] = p; var f = c.prototype[n]; c.prototype[n] = function() { var ts = Game.getUsedCpu(); var rc = f.apply(this, arguments); p.usage += Game.getUsedCpu() - ts; ++p.count; return rc; }; }; wrap(RoomPosition, 'isNearTo'); wrap(RoomPosition, 'findPathTo'); wrap(RoomPosition, 'isEqualTo'); wrap(RoomPosition, 'findClosest'); wrap(Creep, 'moveByPath'); wrap(Creep, 'moveTo'); wrap(Creep, 'pickup'); wrap(Creep, 'build'); wrap(Creep, 'repair'); wrap(Creep, 'harvest'); wrap(Creep, 'upgradeController'); wrap(Room, 'lookForAt'); wrap(Room, 'find'); wrap(Spawn, 'createCreep'); } .... // main code var report_interval = 200; if (Game.time % report_interval == 0) { var summary = 0; for (var n in Memory.p) { var p = Memory.p[n]; if (p.count === 0) { p.average = 0; continue; } p.average = p.usage / p.count; summary += p.average; } for (var n in Memory.p) { var p = Memory.p[n]; console.log(n + ': ' + p.usage.toFixed(2) + '/' + p.count + ' == ' + p.average.toFixed(2) + ' (' + (p.average * 100 / summary).toFixed(2) + '%)'); } console.log('--- ' + summary.toFixed(2)); Memory.p = {}; }Feel free to use it.
-
RE: A potential very fast js pathfinder algorithmposted in General Discussion
chris, probably not. I have slightly optimized the search function by caching neighbors for traversed points. The cache is gone after leaving the function.