Home / How to / XLOG #3 – How to simulate a universe

XLOG #3 – How to simulate a universe

Hello everybody to the new XLOG video For today's video I've found a very nice comment under the last XLOG video with questions from a user from Hamburg and maybe I can touch on all of those four points

Or maybe at least on the first two because they go together very well What I would like to explain today is how different games simulate a universe Today there's a lot of games that call themselves open-world games and there's still a big difference between what an open-world game really is and how it simulates the universe and how deeply it simulates the universe Many of you of course expect such a game to simulate the entire universe because that's the idea that it's selling It's an open world, you have this entire universe in front of you and when you travel through the game you see all those objects – depending on what game it is different things – and it's always telling you that story that all of these things are real

All of those things are simulated behind your back for the entire world But of course that's not really possible and and it depends on the type of game and also the type of audience how much trickery is going on behind the scenes and what they are really doing One type of game in particular that goes further than most PC games are online games because for online games clearly you have to simulate more than just what one player sees because there's many players in one universe and there's always multiple computers involved as well It's not just you and your computer or your console when you are playing but also the servers that are transferring data to your computer There's a stimulation level happening on a server where the world can continue to exist even when you turn off your computer or your console

But even in online games, not everything that you see is actually simulated Even in online games there was a lot of trickery going on and a lot of "cheating" if you will This is especially true nowadays with mobile games Lots of mobile games actually only create the impression that things are actually online when they oftentimes not and even when you see other players it doesn't necessarily mean that they are right now playing the exact same thing that you are seeing Sometimes they are not playing at all

That's a little bit what we are doing with our online mode ("Ventures") where you do know these other people that you see in our online mode in X4:Foundations They're also playing the game, but they are not necessarily playing it right now They have sent their ships into your universe and and they are now a visitor But on mobile games this goes a lot further They oftentimes actually make you play completely on your client on your on your phone, separated from service and only transfer data occasionally

But anyway, that's a different story The point is what's really simulated and what's actually existing in this universe can vary a lot Even in single player games, games that are only there for you, which are only living on your computer or your console, the level in how a universe is simulated can vary a great deal There's at least two games that I would like to take as a comparison to what we are doing to explain why what we are doing is different and why it brings a couple of problems with it and is also a reason for some of our bugs sometimes One example is Minecraft, a game that I really love

It's special in many ways because it's very unique and how it creates its universe It was unique at least at the time when it came out and special because it has this really big world and yet if you look at a savegame it's really tiny How can they fit this huge universe into such a tiny savegame at the beginning That's because everything is generated procedurally That's nothing new nowadays, you've probably heard that from from other games, but Minecraft does it in a very clever way

They basically create an entire world out of just a random number generator and you can have this thing called "seed value", one number that is fed into this random number generator, to always create the same world again and again Theoretically you can store an entire planet worth of life, mines, creatures etc in a single number and it will always be the same when you create it again The trick here is that the world at the beginning is defined very simple, meaning that at the beginning your savegame can also be very small When you then continue to play and you change the world the savegame starts to grow because everything that you touch, everything that you change will now become a real object, will now have to be stored persistently

Otherwise it wouldn't be the same anymore after a while That's what Minecraft does After playing for many weeks and months in one of those savegames, the world data grows and your savegames can grow If you've had a look at a savegame in an X game, you know that we work a bit differently, but we have a similar problem to Minecraft Our universe is also stored entirely in a savegame, because it lives entirely only on your PC and that requires a lot of data and savegames can become extremely big, hundreds of megabytes potentially, but then they are compressed

In Minecraft there's a lot of stuff that is persistently stored, but not necessarily a lot of stuff that is actually simulated That's the other thing: Usually you see the creatures around you, the zombies and the creatures that you can see and clearly these are simulated But the world is so big and there's no need in Minecraft to simulate other creatures at the other side of the planet In fact it wouldn't be good if they did because then these creatures would probably potentially do changes to the world which would have to be stored in a savegame again As long as the creatures didn't even exist then the creeper can not blow up and blow a hole into the map

In Minecraft it's pretty simple: only those creatures around you actually exist and you can play with multiple people on the same map and then you have multiple patches of the map that are "going live" so to speak for for a short period of time and then they go dormant again and the objects cease to exist thereBut the world is saved as a static thing For us this is different There's one reason why we wanted to simulate everything, especially the ships, but also stations and producing factories in our universe that are at the opposite side of the universe They actually are simulated and that means they produce wares, they fly routes and bring wares from points A to B and interact with other NPC agents

The question is why would we do that In the beginning of the game, when you start a new game, it's really crazy We are simulating thousands of ships and thousands of stations in the entire universe and you only see this tiny little bit of it It's a really crazy, but I always thought this is really what makes an X game, that we have this true universe simulation and that it really develops in unpredictable ways oftentimes when it plays out The real benefit of this system for us happens later in the game, when you play for a long time, your influence in the universe grows bigger, and therefore you can see all the NPC's actually reacting to it

That would be something that would be really hard to do if we wouldn't actually simulate all of those objects In our universe it is in a way a "naive true simulation" because that's what you expect Naive as in this is what we are actually telling and it's what's really happening But even in our game that's not the full story, because no game can really simulate everything Every game has to "cheat" a little bit and so the question is always just how deep do you go with your simulation? What objects really need to exist? What objects do you really need to store in a savegame? You always have to make compromises and always have to find something where you can make it save bytes and a way you can save performance

Another example to compare with is another nice open world game: GTA I love both of these games Don't get me wrong here, I'm not criticizing these games, because I'm saying we have this full simulation and these games don't have that Far from it, because you always have to ask yourself why would this game do that Of course it doesn't really make sense for GTA for example to simulate NPCs at the other side of the map, when you drive your car around

Obviously the cars in your near vicinity and everything that you see is simulated, but why would the world of GTA become any better if the game continues to simulate that rocker gang at the north of the map that you'll visit at some point and murder a lot of people and then never see again Why would they have to continue living when you don't see them? Obviously they don't exist or sometimes maybe they store persistent information, so you can meet an NPC again later for storytelling purpose But they are not contributing anything else to the world when they're not seen, so they are not simulated It would be stupid to do it and just cost memory and performance The same is true with with the zombies in Minecraft

The game wouldn't be any better if you simulated all of those creatures in the entire world For our game there is a different aspect and that's the economy simulation, the fact that we are talking about a living economy which influences everything that you see on on that economic level and where you, later in the game, start to participate by producing wares yourself Even when you just destroy a ship, you participate in the economy by draining it and costing factions wares This was always the vision with the X games: this truly simulated economy makes the universe more alive and more real That only makes sense in any economy simulating game

Where in GTA of course there's little trading You buy weapons, but they are not manufactured from the ore and the mountains That wouldn't make any sense there It's just not an economy heavy game But for X games, really that's the root that everything else is built on

We always want to make the game also attractive to players who only enjoy it for the action, who only enjoy it for the missions But even then I believe that the game gets better through this connection with the economy because oftentimes in its best moments the behavior of NPCs, be it pirates, be it the military of a large faction like the Argon Federation, their behavior can be traced back to economic decisions and that's really what defines anX game But it's also the answer, or the biggest part of the answer, to that first question this user was asking It's also what troubles us a lot, it's also what creates a lot of problems I often call this a "bottom-up simulation" as in we are simulating individual little agents like ships, stations, station managers, and they interact with each other and build the universe

We are simulating the little pieces and the big pieces are results of that, rather than the other way around We are not simulating it to create an impression for the player, but we are simulating it really to simulate a universe The opposite approach would be a "top-down design", that you create with the impression the player has in mind first You can also do that with an economy game and I think there's lots like that out there But for economy games I really believe in the answer that "bottom-up simulation", the way I'm describing it, is better than a "top-down" approach, where you might have a nicer gameplay experience in the short run, because you always can make sure the player sees for example the profit that is fun for him

That's the goal that you want to achieve: the player wants to trade and wants to have fun with trading so you design the gameplay experience according to those goals But that would be pretty shallow and if you play it for a while you would see that things are always designed just to make you happy and it wouldn't have that depth of our true universe For the economic simulation part "bottom-up" is the way to go That's what I really believe in, but it also creates a lot of problems and a lot of unforeseen things That's because the simulation is really unpredictable oftentimes

It's a chaotic system You can also see this if you take a savegame and give it to a friend of yours, so that you both load the same savegame From that moment on, continuing to play with that same savegame for a while, you will see that the universe is only the same for a very short momentBecause after a little while it changes quickly because of all of those little decisions you make, which add up Little things add up to big things

The initial changes might be very tiny, but when you let that simulation run for days or weeks then all those little changes in the universe can sum up to huge changes The little changes can be introduced through what you do, as a player That's the "win", that's what we want, that your influence changes the universe The bigger the changes, the bigger the influence But also small things like just the frame rate at which the game is running on your computer may make a difference as in tiny seemingly unimportant differences in NPC decision-making processes or how a ship flies or many other things

That also can sum up so it's truly chaotic in that sense That is what makes it hard for us to debug You can you can already see where I'm going with this What will happen to our economy after playing the game for weeks is unpredictable, completely unpredictable Every time you play the game it is different

The way for us to test the game is oftentimes just letting it run many times We write code to simulate, to program the behavior of different NPC agents, lots of them, and then we try it out in our universe simulation and see how it goes In this chaotic world which progresses differently every time, we can still trace certain patterns and sometimes we see something goes wrong, like a trader not buying the stuff he should be buying and therefore we can look at this AI code and and fix the reasoning The problematic cases are those where you don't think there is a cause and effect, because sometimes it's a very long chain Something tiny breaks somewhere, seemingly unimportant, and only after you trace it down over many steps, suddenly you find that this little thing caused a much bigger thing to fail, at a much later point

Testing for us is really often times letting the entire universe simulation run in an accelerated mode Fortunately that's something we can do, we don't have to run the game in the true speed like it would be running on your computer, but basically with SETA, faster and we can even run it faster than with normal SETA sometimes But even then it is very common for us that we have computers here at the office that are running for many hours, for many days actually, through the night often times and then at the next day we run economy logs That's basically a lot of data stored outside of the game and then we interpret huge tables and look at what's going on We see data from hundreds of stations across the universe, interpret what are they buying, what are they selling, which stations have been destroyed, which faction is growing, which faction is shrinking etc

This was always complicated with X games because this, at its nature, at the root, this was always how our games work, even with the first one, X Beyond the Frontier But of course this level of simulation grew from game to game Now, with every new game, we are giving the factions and the individual NPC's more We simulate more, while "cheating" less That's how you can put it

As I said before, every game has to "cheat" You're never truly simulating everything We always have to make compromises A nice example in our case would be the mass traffic Mass traffic are those little tiny vessels that you see flying around stations sometimes and I see them mostly as a decorative thing, but they also represent something

They are not completely pointless, they are not just decoration You can see for example which types of wares are currently being transported around the station or how many people are aboard a station In that sense they do represent information through actual information of that universe Persistent information But they are not, as entities, simulated when you don't look anymore

They are really just a nice, large system that is created the moment you go there and all those individual vessels are not existing otherwise But all the other ships, the bigger ships, are Even those that are not directly involved in the economy Traders obviously have to be simulated and the factories that manufacture the wares It's not just one object when I'm saying "a factory"

A factory is the sum of many objects It's of course modules Production modules, storage modules, the living sections where the people are in Most of this is just data, like the storage facility is just data, it doesn't have code running It just hasthe data of what's inside, but many things are actual entities executing code

For example the manager on such a station, or the production component Those objects actually execute code, producing wares and the manager influences that again And then the captain of the ship makes decisions about how the ship is flying and then the ship is the data container flying around It's a very big simulation of thousands and thousands of objects, interacting with each other It's truly beautiful sometimes to just watch in awe how this entire universe is developing

That's really the nice thing from our perspective Also for us surprising things happen, it's unpredictable, it's interesting, it's new every time But also hard to debug and problematic We have to be careful with every patch, with every change we make, we have to be careful not to break something It's a constant struggle

I hope this has answered at least the first two of the questions in this YouTuber's comment I hope to get to answer more stuff in the future and I invite everybody who is watching this to also post some questions in the comments below Like and subscribe us Subscribe to this channel if you like these kind of videos and then I hope to see you again soon Thanks for watching!

Source: Youtube

About umoh

Check Also

How To Protect Yourself Against Coronavirus | Katy Tur | MSNBC

>> DON’T PANIC IT IS AN EVOLVING SITUATION IT IS AN EVOLVING SITUATION WE WANT …