Game Screeps. Error during simulation. CPU limit reached

1.2k views Asked by At

I'm going throw Screeps (http://screeps.com/) simulation. I've stick on stage when I need to send worker to harvest resources. So I put code from the tip to the script tab, code is:

var creep = Game.creeps.Worker1;    
var sources = creep.room.find(Game.SOURCES);    
creep.moveTo(sources[0]);    
creep.harvest(sources[0]);    

My creep had started move to source, but then it froze and I got error (light red text) in console:

CPU limit reached

What I need to do to finish this step and why I'm getting this error?

3

There are 3 answers

0
trizz On

From the documentation:

Please remember that the exact duration of the execution of your script is limited by the CPU time available in your service plan. In case of exceeding the limit, the script execution will be stopped. The exception is the Simulation Room where the script execution is always limited by 5 seconds.

So it seems that your creep can't find anything to harvest within five seconds

3
dlkulp On

This appears to be a bug in Internet Explorer 11 (and probably older versions too but I don't have older versions installed). I would create a creep and everything would be fine and dandy until sometime between moving to and starting to collect from a source at which point the entire thing would freeze. I think this is just lazy programming because I was able to get everything working by switching to Chrome 39.blah.blah.blah. If you're not using Chrome I would suggest using it for this game.

0
Lucas Azevedo On

It's a limitation of the Simulation Room mode. Commit the scripts, refresh the page and start simulating again and it should work.