Important change: CPU cost of API methods

The world of Screeps is in constant development, and so are players' achievements in controlling their colonies. Some players have managed to achieve such a high level of optimization of their scripts that they now rule hundreds of creeps simultaneously. We are really impressed by their performance. However, it created a new situation that requires our interference.

The matter is that when a player optimizes control of a large number of creeps so that they stop spending CPU, he or she becomes capable to create a large number of game objects that puts the server under a huge pressure. Our CPU payment system was developed in order to let players compensate their expenses on the server load they create and to encourage optimizations. However, this new type of load becomes unaccounted. It leads to trouble for all the players since we can't scale our servers in such circumstances. We were considering various ways to solve this problem including limiting the number of creeps, but finally decided to act more in the spirit of a programming sandbox game.

Starting from October 12, 11:00 UTC, each API method that changes the game object state (like move, transferEnergy, createCreep etc.) will consume exactly 0.2 CPU rather than zero usage before. The CPU cost of such methods will be marked as CONST in the documentation. I. e., it will look the following way:

var startCpu = Game.getUsedCpu(); 
creep.move(LEFT); 
console.log( Game.getUsedCpu() - startCpu ); // 0.2 
creep.transferEnergy(spawn); 
console.log( Game.getUsedCpu() - startCpu ); // 0.4

If the object state change has already been requested in the current tick, the CPU won't be spent (UPD: this statement is not valid anymore).

If you have 100 creeps, your expenses to move them will be 20 CPU even in the case you don't use any pathfinding computation. By optimizing your colony so that the same functions are performed by 50 creeps rather than 100, you will get the effectiveness increase by 10 CPU.

Therefore, saving CPU will require you to optimize not just code algorithms, but also the game tactics itself, using creeps, and enlarging their bodies.

While we understand that all the players will see CPU usage increase in their scripts, the game in general will benefit from it: we'll be able to calculate our server expenses and scale them more precisely, which will give us faster ticks and better gaming experience for all the players.

To compensate for some negative after-effects of this change, three more edits will be implemented in parallel:

  • The maximum creep size will be increased from 30 to 50 parts.
  • Roads will be possible to build with any RCL, even zero, i.e. in neutral rooms and rooms without a contoller! You'll be able to build paths to your remote mining area by decreasing the required number of MOVE body parts and enlarging carrier creeps (the optimal configuration for a carrier on a road is 16M 32C).
  • During a limited time period after this change, a special promotion will launch: the 14,000 CPU Credits package with 40% OFF the base price of a Credit, so you pay just $28! This promotion will last one week, till October 19.

 


 
UPD: The CPU change will be implemented gradually as the cost will slowly increase according to the schedule:
  • October 12: 0.05 CPU per operation
  • October 14: 0.1 CPU per operation
  • October 16: 0.2 CPU per operation
Have more questions? Submit a request

Comments

  • Hernanduer

    Will we be able to build roads to the boundary line rather than the 2 tile limit we have right now?

    Also will pathfinding still use more than 0.2 CPU or not?

  • RaskVann

    I'm not seeing the promotion on the https://screeps.com/a/#!/order page. When does it go live?

  • NhanHo

    Can we have a few more days (a week or something) to change our code? A 3 days notice is insufficient and my script will straight up stop working even at max CPU allowed.

  • Avatar
    Anton from Screeps

    @Hernanduer I can't say about the roads, this is under consideration now. As for the pathfinding, yes, certainly. This is your direct script usage, it won't be changed.

    @RaskVann The promotion will launch on Monday simultaneously with the aforementioned changes.

    @NhanHo We considering gradual implenetation starting from a small extra CPU cost and then slowly increasing it. Wait for more information tomorrow.

  • Sargeth

    Another interesting point was raised on the FreeNode irc channel. Many basic scripts don't save state and have creeps perform for instance moveTo() and harvest() constantly. Depending on the location of the creep one or the other will always fail but currently that's not a problem. Will a creep in such a case be charged 0.2 CPU for both actions, even if only one ever takes effect?

  • Avatar
    Artem from Screeps

    @Sargeth: CPU will be consumed only when OK result code is returned.

  • XyzzyPrime

    So moveTo() and move() both take 0.2 CPU when OK is returned?

     

Powered by Zendesk