PTR Changelog 2017-07-20: world shards


  • Dev Team

    What if instead of all of the shards having automatic access to each other shard the code can request it (similar to requesting a foreign segment from another player)? This could potentially make it less tightly coupled.

    This is an option, but it introduces more complexity to this mechanic. Let’s see how it goes with interShardSegment on the PTR. I suppose all what you have to implement is some mutual locking mechanism based on real time, not on game tick. Shouldn’t be very hard to come up with.

    bots on private servers will not be able to use multiple shards

    Private servers aren’t going to have shards support at all (at least officially).

    Please reconsider this, as I think it’s a huge mistake that this isn’t in the roadmap.

    Shards resources (not just CPU, but also GCL, Power Levels, Pixels, etc) are entities of higher order than those that your scripts are operating with. Giving an ability to allocate shard resources using the game API is similar to providing an ability of, say, changing your badge or email via the API. It is related to your account and should be set up by user, not by user’s script through an in-game mechanic. The shard itself knows nothing about the multi-shard environment it exists in, similarly to how it knows nothing about other user metadata like emails.

    That being said, you can always use our web endpoints (they will get official Web API keys soon) to act on your behalf if needed.


  • Culture

    > Private servers aren’t going to have shards support at all (at least officially).

    That's disappointing, but I'm pretty sure it'll end up with unofficial support at some point.

    > Shards resources (not just CPU, but also GCL, Power Levels, Pixels, etc) are entities of higher order than those that your scripts are operating with. Giving an ability to allocate shard resources using the game API is similar to providing an ability of, say, changing your badge or email via the API. It is related to your account and should be set up by user, not by user’s script through an in-game mechanic. The shard itself knows nothing about the multi-shard environment it exists in, similarly to how it knows nothing about other user metadata like emails.

    To me this just says it's a challenge, not that it's impossible. Perhaps a special "intent" which literally just makes a call against the API you're building would resolve this. The shard doesn't need to know about the multishard environment in any way that can't be managed with the shared segment (for instance, if there are ten shards and I'm on three of them I should be able to figure that out in my own code without needing assistance from the game engine, which also means I should be able to make the adjustment from the shard with all the info I have).

    `setShardCPU({shard1: 50, shard2:30})` on shard1 triggers an intent for changing data. The engine sees that intent and (for performance reasons) dumps it in a separate queue, and that queue gets processed and literally just makes an HTTP request against the API you're already building. Sure there may be some lag between when the command in game is sent and the CPU gets allocated, but I think that's pretty fair.



  • re: CPU -- it would be nice to be able to set this in script. To avoid excessive synchronization maybe have one shard be a CPU-master (whoever claims that status first) and be able to allocate CPU for own and all other shards. If script wants another shard to be master, current master must relinquish the status first.

    re: segment sync -- there absolutely needs to be a way of synchronizing this, currently I don't see a way of writing into it from more than one shard. At the very least we need 2 independent segments as tedivm said.


  • Dev Team

    I meant it's more of an ideological restriction than technical. Such things should be changed via Web API, not via Game API.


  • Culture

    > I meant it's more of an ideological restriction than technical. Such things should be changed via Web API, not via Game API.

    Why? Why should players who babysit their computers be given an advantage over players who focus on automation- what is the "ideological" reason for that?



  • Shards resources (not just CPU, but also GCL, Power Levels, Pixels, etc) are entities of higher order than those that your scripts are operating with. Giving an ability to allocate shard resources using the game API is similar to providing an ability of, say, changing your badge or email via the API. It is related to your account and should be set up by user, not by user’s script through an in-game mechanic. The shard itself knows nothing about the multi-shard environment it exists in, similarly to how it knows nothing about other user metadata like emails.
    That being said, you can always use our web endpoints (they will get official Web API keys soon) to act on your behalf if needed.

     

    Is it only me or this answer doesn't make any sense at all - "higher order" or not, your CPU availability matters to how your script can play the game - changing the badge, email address and so on doesn't have any significance to the game itself and can be done manually or not at all. And the "shard" (if it matters at all) knows about the multi-shard environment - it has portals to the other shards - it's not like these are separate servers, but something that, at least i think we are, trying to make work altogether.

    So in the end you want us to write a 3rd party script to send data between the shard. If not already, at the near future, that mechanic will be used to do any heavy processing or preprocessing outside of the game thus bypassing the CPU limit and making it uneven for anyone who doesn't do that.

    Again, don't know if it's only me, but these 2 points seem really really wrong and totally not in the direction i want the game to be heading 


  • Culture

    For the record, I agree with artem on the seperation of user and engine data

    @unfleshdone theres a few easy ways to handle interShardSegment, one I'm thinking of is just a hash list of timestamps when each shard updates, then only the lowest timestamp is allowed to write


  • Culture

    ags131 - can you provide actual reasons for that? What about the game play is improved by this distinction? 


  • Culture

    @tedivm currently the engine is in 3 very distinct parts:

    • storage (db/redis)
    • backend (API endpoints + websocket)
    • engine (in 3 sets of modules,main(master), runners (usercode), and processors(intents))

    While backend and engine share access to storage, they do not have ANY direct ties, and engine only ever writes world state(Objects, memory, etc) within storage, never user state (Such as code, badge, email etc).

    This is a good example of seperation of concerns in action, only the backend is allowed to modify userstate, and in limited cases such as for construction, submit intents for the engine to see. The engine never modifies user state and only sends back 'update' events for world state changes the backend subscribes to.


  • Dev Team

    I don’t see a way of writing into it from more than one shard. At the very least we need 2 independent segments as tedivm said.

    There are a lot of ways of writing into it from any number of shards. It’s a coding challenge of how to implement it effectively. I recommend some reading about mutexes to get more info on the matter.

    Why? Why should players who babysit their computers be given an advantage over players who focus on automation- what is the “ideological” reason for that?

    Those who babysit their Screeps gameplay will be in advantage in much more serious ways than CPU allocation. It’s how online games work, no matter how much we wanted the opposite.

    And the "shard" (if it matters at all) knows about the multi-shard environment - it has portals to the other shards - it's not like these are separate servers, but something that, at least i think we are, trying to make work altogether.

    Portals to other shards are just string properties with the shard names. Database for shard1 contains a portal with shard0 string in it. No metadata from the shard0 database is fetched into the shard1 environment.

    So in the end you want us to write a 3rd party script to send data between the shard.

    You can transfer data between shards without any 3rd party tools. RawMemory.interShardSegment is the only API you would need for that.


  • Culture

    > Those who babysit their Screeps gameplay will be in advantage in much more serious ways than CPU allocation. It’s how online games work, no matter how much we wanted the opposite.

     

    That doesn't justify making the situation worse. I still don't understand the "idealogical" reason for purposefully crippling players scripts here.



  • Not just that, but the stuff around making power creeps be UI only without programatic controllers just highlights this discrepancy. In a game about coding an independent AI (and thats what makes this game special, not any sort of micro) I feel it should always strive to not require the user's control.

    @artem

    Btw, are you considering having power creeps on a shard before they are brought to the main world? I think that would be a great way of implementing them as an opt-in testing experience. Just make power creeps not able to use shard portals and let people duke it out and find all the bugs there. Also give a limit to the amount of power you can use in the shard and a lot of the concerns about a level playing field fall away.



  • There are a lot of ways of writing into it from any number of shards. It’s a coding challenge of how to implement it effectively. I recommend some reading about mutexes to get more info on the matter.

     

    Ah, I guess the write itself is at least atomic and all shards will be presented with consistent state at all times (which one being undefined), so a lock is easy to write. I was imagining partial writes and other horrors. Nevermind then, sync is not a problem. 🙂


  • Culture

    @ags131 - since Artem already said the reasons were idealogical, not technological, your response doesn't seem relevant to the conversation. I asked what idealogical reasons you agree about here.

    I'm also confused how your separation would work with power creeps. Do you not think that players should be able to programmatically design power creeps? If you do think that should be allowed why are you making an exception for them but not for CPU time?

     


  • Culture

    @tedivm The idealogical reason (at least in my mind) is for seperation of concerns and design. Right now, with shards, there are theoretically infinite engine world states sharing one user state, if every engine decided to start modifying userstate, that breaks the whole concept of them being seperate. 

    I do agree that power creeps should be designable programatically, to me, they should be spawned exactly like a creep, but with a 'level', and point allocation  (Eg: `{ [POWER_KILL]: 4, [POWER_TELEPORT]:1 }` to make them entirely world state. The UI could still work by just submitting the UI customized intent similar to construction sites.

     


  • Culture

    My two cents on being able to control CPU distribution from game code:

    One of the things I would love to do with my AI is implement nomadism; code is always looking for new homes, never keeping a room for too long, exploring and finding new neighbors to interact with, whether the result is friendly trade, unbridled conquest, or crushing defeat. It sure would be nice to be able to have my code opportunistically expand into a shard without having to check on it myself, carefully evaluate the CPU / GCL allocated to each shard I'm currently on, and manually redistribute based on how much I think my code might want there.


  • Culture

    > Shards resources (not just CPU, but also GCL, Power Levels, Pixels, etc) are entities of higher order than those that your scripts are operating with. Giving an ability to allocate shard resources using the game API is similar to providing an ability of, say, changing your badge or email via the API. It is related to your account and should be set up by user, not by user’s script through an in-game mechanic. The shard itself knows nothing about the multi-shard environment it exists in, similarly to how it knows nothing about other user metadata like emails.

    I don't know how to say this less aggressively, so sorry for this, but: how can you be so wrong about your own game?

    Let's start with this:

    > Giving an ability to allocate shard resources using the game API is similar to providing an ability of, say, changing your badge or email via the API.

    No. My code can't see my email or badge at all. They do not affect my code's gameplay in the least. No matter what my badge looks like, or my email is set to, it has no effect whatsoever on the game. Allocating shard resources heavily affects the game.

    >  It is related to your account and should be set up by user, not by user’s script through an in-game mechanic. 

    No, it is related to my AI. My AI already knows about the amount of CPU allocated to it (currently, 100%, of course) and its own GCL.

    > The shard itself knows nothing about the multi-shard environment it exists in, similarly to how it knows nothing about other user metadata like emails.

    The shard itself is the server I'm playing on. It's not my AI. After the shattering, my AI will be a distributed system. It will exist on multiple shards. Crucially, it will be able to communicate between those other instances of itself using the shared segment. From here it is utterly trivial to compile a list of the shards I am running on - all I need is for a list of shards to be in the segment, and every tick my AI reads the list, checks its own shard name, and if it's not on the list, adds that shard to the list. Now I have a list of shards I'm running on. I know quite a bit about the multi-shard environment I exist in.

    I still don't know anything about emails, of course, because emails aren't related to the game in any way.

    I also can learn about new shards that I'm not running on simply by scouting portals. And that brings me to my main point:

     

    If you don't let us dynamically allocate CPU to different shards, then claiming a room on a new shard will always involve user intervention. If my code encounters a portal to a new shard, and it would like to expand across to the new shard, without an API the best my code can do is literally send me an email so I can log into a web UI and alter allocations. This is utterly ridiculous. It's completely against the spirit of this game. You have just caused emails to actually be a gameplay mechanic! My code has no way to get into a new shard without emailing me!

    A similar argument applies to power creeps, of course, but this is even more ridiculous. You give me a single segment to write to and manage mutexes in, claiming that it makes your AI code more interesting - essentially handing me a distsys problem to solve on a platter - but then you decide that I shouldn't be able to manage the distributed system that is my AI programmatically? What?

     

    I hope you reconsider. There is a significant difference between "Of course people who babysit the game will have an advantage, it's just a law of physics" and "We are specifically coding this in such a way that people who babysit the game will have an advantage because we will make it impossible to use this feature any other way."


  • Culture

    @tedivm The idealogical reason (at least in my mind) is for seperation of concerns and design. Right now, with shards, there are theoretically infinite engine world states sharing one user state, if every engine decided to start modifying userstate, that breaks the whole concept of them being seperate. 

    That sounds like technical concerns, or maybe just your sense of "programming smell", which the admins have already dismissed as not being the reason for their decision.

    Even still I don't understand the concern. Users can modify the "shardSegment", and you want them to be able to create power creeps, so we're already breaking that divide in at least two places. Your method for having power creeps spawn is going to have to know how many power creeps are already spawned, or each shard will be able to spawn up to the user's power level. So the shards are going to have to communicate with the account system, or in some other way, already.

    Further once the shard allocation is set by the user in the UI it's going to have to get pushed to the shards anyways.

    I guess I don't see the concern with having the central account system be a microservice that other shards can talk to. I do agree that there is no reason for changing things like email or badges via the game API, but being able to communicate about power creeps seems like an important requirement and so does CPU management.


  • Culture

    Honestly, imagine if the market had been released in the opposite state as it was. Instead of there being no user-facing UI to place orders, that's the only way that we can place orders. Code can only look at the orders on the market, in order to actually buy from an order you'd have to go to the UI.

    After all, the market doesn't affect gameplay. Credits exist outside of gameplay, they're tied to your account. Having more or less credits doesn't affect your AI in any way, so it can't even see them. All your AI can do is look at the market and send you an email going "Hey, it'd be pretty cool if you bought X from this order", or "Hey, could you put up these excess resources as a sell order?"

     

    We'd have called you insane, and rightly so. That obviously isn't what we want out of a game that's about automation.

     

    That is exactly what is going on here.



  • Since we are getting pretty heated here, I think its probably good to point out that everyone is surprised and impressed that shards are in a testing state so soon. We know there will be plenty of development and tuning involved, but thank you for addressing this in a timely manner. 

     

    That said, I think people are getting concerned about the direction the game is going. Given that this is a game about automation (#factorio) and writing code, specifically limiting that is something that would of course irritate the people that are drawn to this game for that exact reason. 

    As for CPU, I think that it should 100% be controllable by code. 1 min example of what I as a user would want.
    Game.cpu.maxCPLimit = total account CPU
    Game.cpu.shardCPULimit = cpu the shard is allocated
    Game.cpu.setShardCPU = Set your cpu allocation on the shard. 
    Game.cpu.freeCPU = Amount of CPU allocated to your account not currently used in one of the shards.

    In order to increase the amount of cpu a shard has, you have to have unallocated CPU in your account. So to shift from shard to shard, you reduce your cpu limit in that shard, so for a number of ticks you are effectively missing account cpu as it sits unallocated. Once it registers that you have spare cpu you can increase your limit in another shard by up to that cpu amount. 
    That way with the memory segments you can request CPU from your other shards, but it also prevents frequent flipping around as it results in wasted spare cpu.

    I would have new cpu from gcl etc go to whatever shard has the highest existing allocation, unless the user sets a default shard.