Ticks Used



  • Just a fun idea so we can judge how relatively efficient we are. If you add this to the end of your code. We could compare how efficient we are being, and also have a sort of target for how good we could be doing. I'll post my results in ~ an hour.
    if(Memory.cpuTicks && true){
    Memory.cpuTicks = Memory.cpuTicks + 1;
    Memory.cpuTime = Memory.cpuTime + Game.getUsedCpu();
    Memory.creepCount = Memory.creepCount + Object.keys(Game.creeps).length;
    //console.log(Memory.cpuTime + ' ' + Memory.cpuTicks);
    } else {
    Memory.cpuTicks = 1;
    Memory.creepCount = Object.keys(Game.creeps).length;
    Memory.cpuTime = Game.getUsedCpu();
    }



  • It's a nice idea, but I think you can't compare each others code like this (in a representative way). The execution time also depends on the amount of code you've written and how much function calls you have. In general, a beginner most likely will be quite efficient, because they have not much logic. Advanced players, (although perhaps with more efficient routines and caching and everything) still might use more CPU/creep simply because of all the AI the beginner does not have.



  • Agreed, it would likely be comparing apples to oranges, but here's mine anyway.
    Avg tick: 26.364
    Avg creeps: 51.741
    Avg Tick/Creep: 0.510
    What I was thinking is if someone was way out of line and doing well, it would give us a benchmark to try and shoot for. Also it would give a beginner something to shoot for, as the code you get when done with the tutorial has a lot of room for improvement.



  • There is some "static" CPU consumption not related to AI at all (for instance, cpu used for loading modules).



  • Avg time is 33.61295269903676 with 72 creeps.



  • Another interesting statistic I collect is how many times my script overrun CPU allotment ( 407 times)
    I am at 80 CPU.



  • Amount of cpu overusage is more interesting, I think. Using this one can calculate average overuse to understand how close it is to the limit.



  • average CPU consumption: 14.77
    average creep count: 45.24
    number of rooms: 4
    CPU limit: 20

    I want to optimize my code but do not have enough time 😞



  • Optimized a bit:
    average CPU consumption: 11.64
    average creep count: 55.88
    number of rooms: 5
    CPU limit: 20