Optimizations roadmap


  • SUN

    What are your plans for the existing world should 'shards' be implemented?

    I understand it will depend on the implementation, but is the world going to divided up or reset? (Or neither? (Side by side with a mass migration? that'd be cool))


  • Dev Team

    What happened, why was this abandoned?

    I just feel that there are ways to shard the database without requiring complete different worlds with their own separate tick times. Divergent tick times make things a lot more complicated, and not in a good way.

    Believe me, we tried all kinds of good and black magic regarding classic database sharding. It just doesn’t provide the desired level of scalability in comparison to this architecture shift. We are quite positive that world sharding is more correct way to implement horizontal scalability than database sharding.

    Depending on accessibility, players on a faster shard get an advantage over players on a slower shard. If a portal is open, the player on the fast shard can mine more power, harvest more energy and spawn more creeps than a player on the other side, giving a serious advantage.

    This is a temporary issue. Eventually shards will become self-balanced, when more and more players would want to benefit from the faster shard, making it slower and the old shard faster.

    It adds another player of complexity for smaller players to overcome when setting up multiple rooms / spread rooms.

    We predict that only a few percent of players will be up to establishing cross-shard colonies.

    Presumably respawn zones will often be in shards, to drive players off the main shard to decrease tick times - how much will this stagnate the main map?

    Both respawn and novice areas will still be created at every shard.

    One of the aspects that makes Screeps such an interesting game in the single world. Much like Eve online it creates a political environment that is exciting. I’m concerned sharding the game will fracture this, and lessen the overall political scene in the game.

    I’m interested to see how this idea develops, but really I hope you figure out a way to shard the game without separate worlds.

    The world is still single, just consists of connected shards. Eve Online is actually a great example of this, since they implemented the same idea of different game speed in different regions of space - so called “time dilation” mechanic.

    We would only be able to user 300 CPU per shard, if your GCL is above 27 you have no choice but to expand to a different zone.

    CPU limit is per account, not per shard. Say, if you have GCL 28, and 100 CPU allocated to Shard1, then you have only 200 CPU in Shard2.

    What are your plans for the existing world should ‘shards’ be implemented?

    The existing world will become the first shard. Nothing else will happen to it.


  • Culture

    > I imagine them being a building which can transport creeps to another planet. The success of it depends gravely on it’s implementation. We could be able to build “portal hubs” but only 1 per player (globally owned structure). I don’t think “random portals to another shard” is a good idea.

    I actually think that the new shard should be easier to get to than that, and that the entry/exit points should be in neutral rooms (perhaps in the same rooms as the NPC terminals). If the other world is going to have higher tick rates then people on the old world are already being punished- making it harder to access the faster world is just salt in the wound. 

    I really think the shard idea would be easier to deal with if the tick rates and time were kept close together, even if it does mean throttling the new shard when it gets too far ahead.


  • Culture

    > We predict that only a few percent of players will be up to establishing cross-shard colonies.

    > The world is still single, just consists of connected shards.

    What it sounds like is that the world will in theory be a unified world but in practice will actually be separate worlds.

    > This is a temporary issue. Eventually shards will become self-balanced, when more and more players would want to benefit from the faster shard, making it slower and the old shard faster.

    The old world has a lot of baggage- zombie players on 10cpu, or just somewhat inactive players who don't mind paying but also don't do anything. I don't think relying on it eventually balancing it out is the best way to handle it. New players will naturally spawn to the new server but older players (the ones who have supported the game the most) have established themselves and many of them will not make likely make the jump. I don't think the shards are likely to balance out soon.

    I think the sharding idea can be a good mechanic, but I really think that the "single world" concept needs to be embraced. To me that means tick speeds mostly synchronized (there can be variation, but it should average out to about the same) and easy travel between worlds. In my mental model of the screeps world I'm viewing shards as another dimension- a Z axis to go with the X and Y (or in this case north and south) and would like to see "elevators" in all the highway intersection rooms for going between levels.


  • int_max

    So, how shall the market work between shards?


  • Dev Team

    The old world has a lot of baggage- zombie players on 10cpu, or just somewhat inactive players who don’t mind paying but also don’t do anything.

    Scripts of players without subscription stop working after 30 days of inactivity (no log into the game during 30 days).

    I don’t think relying on it eventually balancing it out is the best way to handle it.

    If it doesn’t balance itself, then we’ll start to balance it manually. Eventually our goal is to provide lower tick rates for all shards.

    In my mental model of the screeps world I’m viewing shards as another dimension- a Z axis to go with the X and Y (or in this case north and south) and would like to see “elevators” in all the highway intersection rooms for going between levels.

    Exactly, you got the idea of it. I can’t tell for now where those portals will be located, but what I can tell is that they will be neutral, and there will be plenty of them so that everyone can access. Inter-shard portals can be considered just another type of inter-room exit tiles. As long as all interested players can easily move back and forth, it remains the same idea of a single world consisting of isolated game zones (rooms/shards).


  • YP

    > So, how shall the market work between shards?

    They would be seperated... otherwise the economy of a new shard would already broken from the beginning 😉

    > I really think the shard idea would be easier to deal with if the tick rates and time were kept close together, even if it does mean throttling the new shard when it gets too far ahead.

    But the lower tick rate on the new shard is one of the only things I can think of why you would want to spawn on a new shard.

    > The world is still single, just consists of connected shards. Eve Online is actually a great example of this, since they implemented the same idea of different game speed in different regions of space - so called “time dilation” mechanic.

    It's a bit like apples and pears ... the time in eve online is only slowered in the star systems where currently a big combat is happening ... it has no impact on the econoly... and it is one of the most hated systems in eve online 😉

    It more reminds me on a mmog I played several years ago .. I currently don't remember the name. players and guilds could create villages and build cities and one of the features was that you can move your guild to other servers. Later there were guilds that were not interested in building cities but to only move from server to server and destroy others stuff 😉


  • Dev Team

    So, how shall the market work between shards?

    They will be fully isolated. But you can start doing some import/export shenanigans between them, might be quite interesting way to raise some credits 😉


  • Culture

    I think the portals will have to work a bit differently. The room bouncing problem is already bad enough when your script is running on one server, but having to send a creep and have another script grab it at the right tick sounds like an amazingly frustrating experience. Having "entrance" and "exit" portals for each side, so a creep can get on a square in one world and end up on a non-portal square in another, with no concern about bouncing between the two.

    I also think Memory should be completely independent so one server doesn't overwrite the other. Being able to request segments from different shards would give a useful communication channel.


  • Culture

    > But the lower tick rate on the new shard is one of the only things I can think of why you would want to spawn on a new shard.

    If the worlds are connected in a stable way then I would happily put an outpost on the other server, and build up on both sides. Having bases that players can't get to without either respawning or investing in extra-dimensional portal traversal seems like a huge strategic advantage.


  • Culture

    > They will be fully isolated. But you can start doing some import/export shenanigans between them, might be quite interesting way to raise some credits 😉

    Credits too? Will subscription tokens be the same across shards?


  • Dev Team

    I think the portals will have to work a bit differently. The room bouncing problem is already bad enough when your script is running on one server, but having to send a creep and have another script grab it at the right tick sounds like an amazingly frustrating experience. Having “entrance” and “exit” portals for each side, so a creep can get on a square in one world and end up on a non-portal square in another, with no concern about bouncing between the two.

    Activating a portal would most likely require some explicit action like Creep.moveToShard(portal, shardName) since the same portals may be used for more than two shards in the future.

    I also think Memory should be completely independent so one server doesn’t overwrite the other. Being able to request segments from different shards would give a useful communication channel.

    Memory and segments will be independent to prevent race conditions, and due to loosely coupled architecture (runtime workers will be connected only to their shard’s database, not to others’). We still need to figure out some way to pass messages between shards in an asynchronous manner though.

    Credits too? Will subscription tokens be the same across shards?

    Can’t tell anything for sure now. We need to prevent race conditions on operations with credits and other account-wise resources like tokens. It can be achieved by either introducing locks and mutexes on such operations (reducing the performance), or separating their balances on each shard with an ability to transfer between them.


  • Culture

    > Can’t tell anything for sure now. We need to prevent race conditions on operations with credits and other account-wise resources like tokens. It can be achieved by either introducing locks and mutexes on such operations (reducing the performance), or separating their balances on each shard with an ability to transfer between them.

    Either way if you do this (split balances) it would be really useful if you also added in the market functions to transfer credits between players. If two players are in completely different shards they can't use the "expensive energy order" trick to transfer credits so there will need to be some mechanism there. It would also be nice if there was a client side or api level way of transferring credits, since even with the above mentioned transfer function it still requires an active room for console commands and with the multiple shard system that may end up being complicated.


  • YP

    while credit transfer would be a nice thing, I think even better would be private market entries... so you would add a receipient to the market order and no other player could see or accept the order.

    to better arrange those transfers/deals some kind of in in-script messaging would be great of course 🙂



  • you can "in game message" now with public memory segments.


  • YP

    > you can "in game message" now with public memory segments.

    really? how do you send someone a message with a public segment? do you put your message in there and hope that they read your segment in the near future?

    do you scan every players public memory segments for messages ?



  • Well, I'd suppose you'd have to write one, but two people that know (or a large group that knows) to look at a certain segment could use that as a place to store "messages" that other people that know where to look, could read and process.

    One thing is for sure, I don't need yet another source for spam. So no Game.notify("coteyr", "my message here") or anything like that.


  • YP

    How would you spam someone? The messages would get delivered to an array that has to get read - or ignored - by your script.. you would not even notice the messages if you don‘t look for it. I don‘t think many people will be interested in wasting cpu by sending messages to people who would not even notice that they got a message.

    I still don‘t get how you would do the group messaging using public segments. How do you store your messages in someone else public segment? It‘s easy to publish data but it‘s impossible to tell someone to fetch your data without using a terminal hack or something like that. Checking every other players public segment one by one every tick will take a while if you want to communicate with a group of people like your alliance and neighbors.


  • Culture

    (Answering with own ideas, not as a Screeps official)

    Activating a portal would most likely require some explicit action like Creep.moveToShard(portal, shardName) since the same portals may be used for more than two shards in the future.

    That’s a nice solution. The bouncing between shards could cause big issues due to different tick times.
    Will the creep memory be passed along? I’d love to at least give it some purpose once it’s on the other side.

    We still need to figure out some way to pass messages between shards in an asynchronous manner though.

    You could probably make a memory segment public per shard, which you can load in other segments. It could be loosely coupled

    RawMemory.publishActiveShardSegment(id)
    publishes data exactly once in a synchronous matter. This way there is no need to keep it up to date every tick.
    RawMemory.setActiveShardSegment("shardname")
    set active shard data on the shard it’s run on
    RawMemory.shardSegment["shardname"]
    get data from the raw memory

    That could fit nicely in the architecture without too much work. I’d grade cross-shard operations as an “advanced game mechanic” anyway, so doing it with segments seems like a good idea.

    @W4rl0ck

    I still don‘t get how you would do the group messaging using public segments
    You could do the following in your code:

    RawMemory.segments[0] = "hi bob";
    RawMemory.setPublicSegments([0]);

    Another player could do:

    RawMemory.setActiveForeignSegment("dissi", 0);
    // Next tick:
    var messageFromOtherPlayer = RawMemory.foreignSegmentobject.data;

    This should at least get the messaging going


  • YP

    @dissi: it was not a technical question about code.. I know how to get public segments of other players.

    The problem is the other player would not know when I put some data into my public segment... so the plan is to put something into a public segment and then tell somebody in slack to fetch it?