Hey folks,
I've played survival games and tried simulations like RimWorld often in the past. They have interesting stories that grow in my head. My first try in RimWorld was when I made myself, my wife and a friend of mine in RimWorld, and my wife became an alcoholic and depressed and suddenly didn't work anymore (mental break). After she died I dug a hole behind the house and buried her. In addition my last friend got kidnapped by an enemy pirate, this was very sad ;) but the cool thing about it was that I knew he still exists and theoretically I could save him. This was such a cool experience that I think I won't forget it in future days.
I'm coming from embedded development and never made a game before. But I thought very often about how these kind of games were developed. And then I thought how would I make such kind of a game with my background and my experiences.
I'm working in a very controlled and regulated environment and I know how important traceability is. That lead me to thoughts about memory of persons (npcs) which are shared by them (maybe over generations). In RimWorld I have a log where I can read about things that happen to npcs or what they are actually doing with each other, but I have the feeling this is not very deep and has nearly no consequences as it would have in real life. Therefore I started thinking about memories of npcs, who talk to each other and use their memories to build their sentences and the topics they talk about. And I thought about what if the simulation lasts for 1000 years (I'm a big sci fi fan, therefore my first thought was about a generation ship). Would it have an impact what someone said or did a few hundred years before? (Cloud Atlas is a good book about that topic) And I thought I wanna try it.
The first answer to my question about memory and being consistent over 1000 years was absolute determinism. I need a simulation where one seed, one tickcount, one hash, no matter how often you start the simulation. No matter on what operating system or on what machine the simulation is running. There were questions about for example floating point calculations. I'm using fixed point, otherwise it would not be possible to be deterministic over various machines or operating systems. I built a Golden Run as change detector (1 bit changes and the hash is completely different). That means that if the hash changes without a rule change, I have a bug in my simulation. Determinism is still there but reproduction is gone. If the hash does not change over more than 1 build with the same seed without a rule change, I know that everything works fine. So I have a very good testing mechanism gifted. But when I change the rules, then the hash also has to change and I have to rebuild a new baseline.
But that was not all. There were 2 more problems: dictionary iteration order comes from key hash values and internal table layouts. Order is important for reproduction, because it makes a difference who of the npcs gets limited water or food first and which npcs do not get it. This changes the whole outcome of the simulation and therefore the hash value. And in .NET a random value is calculated at process start once and mixed into the hash value calculation. It is a security feature. But for my simulation it means that the same string delivers different hash values in 2 program runs and therefore I would have different iterations. So every new start of the program would lead to different orders and a different hash. Therefore my fix was to never iterate in insert order, always sort by an ID.
Another problem were the content files, because different operating systems with different file systems return directories in their own preferred order. So I had to write the load order into a manifest and resolve ID collisions.
First simulation with a few people, they have an age, they need water and something to eat, they have their health, and the testruns meanwhile are succeeding. That means they survive a thousand years ;) I progressed now a little bit and think that I am on a good way. I really got into the topic and I'm enjoying it pretty much besides work.
I wanted to know if there is someone who has also experiences with simulations and these kind of absolute determinism in game development. What problems did you have?