Changes in the runtime engine

Good news screepers!

We have redesigned some architectural solutions in the engine that executes your scripts inside the game. Here are some of the improvements you can notice starting from now.

Non-blocking exceptions. Many of you have asked that the console output be visible even when the script throws an exception. This is convenient for debugging and tracking the moment the error occurs during the execution of a script. It is possible now - script execution errors don't block either the console output or the game commands execution! In other words, all the commands that were fixed before the occurrence of an error will be executed:

Game.creeps.John.move(LEFT);
Game.creeps.Michael.move(LEFT);
throw new Error('error!');
Game.creeps.Bob.move(LEFT);

Creeps John and Michael will successfully move to the left in this tick despite the thrown error.

Note that this even refers to the error of CPU limit exceeding. Thanks to it, you can now arrange priorities of your creeps logic so that the most important actions perform in the beginning of the script and don't risk being unexecuted due to the lack of CPU resources.

Persistent global scope. Previously, the sandbox scope for your scripts execution was created from scratch every tick. It allowed safe isolation of the script but wasted some CPU per tick. We found a way to circumvent this. Now the scope is recreated only from time to time, while the majority of ticks of your game script execution use the same global scope. According to our estimates, it will save about 10-40 CPU for each player. Besides, there is a keyword global now available in a script which affects some outside scripts and compilers.

Have more questions? Submit a request

Comments

  • ir0x539

    sweet

  • nugarin

    Very nice!

  • chris

    Thank you very much, this is indeed a very good change. What I would like to see in the future, is to have this also done with our prototype declarations which are pretty much static as well. This would go well with the change, that the console is now considered before the execution of the main (means, our custom prototype function are not available any more :-( ) After all, the game should not be about how long it takes to prepare the code, but how efficient it is;)

  • ZorzZ

    This would be AWESOME if it worked as advertised. Unfortunately, most times I exceed the CPU limit, I instead get this error:

    http://support.screeps.com/hc/communities/public/questions/201276401-TypeError-Cannot-read-property-length-of-undefined

    When that happens, I lose console output and prior commands, just like before this improvement.

Powered by Zendesk