itch.io is community of indie game creators and players

Devlogs

Super Regions and Expanded Simulation Time

Worlds - History Simulator
A downloadable game for Windows and macOS

This weekend I started adding super regions, which will are just regions that are composed of other regions, or subregions. This is in part needed to be able to partition the bigger biome regions into smaller sub-regions without erasing the original region altogether. This will also help in the future to build regions around entire subcontinents or continents.

A big problem reared its head while implementing super regions though. Because now regions and subregions can share cells, there's a big chance they could also end up sharing IDs, which is not good because IDs are supposed to be non-random, non-sequential, and  also unique. So, I started brainstorming for a better way to define region IDs that comply with all of those characteristics even two regions share the same "space". Although the solution I came with requires revamping the game's entire ID generation system...

One detail of the game that a few players have noticed is that it can only run a simulation for 9,223,372,036 days. which is roughly 25 million years. This seems like a huge number. But the game can easily reach that number in less than an hour if there's little activity in the world (a common occurrence on wasteland and desert worlds). And the whole reason that time limit exists is because the in-game entity database uses dates, along with IDs, to generate 64 bit database keys. I use 28 of those bits for IDs, which means I'm left with only 36 bits for dates. But the new mechanism I want to use to generate IDs would require me to use even more bits for them, and less bits for dates. Meaning I would be left with a way shorter maximum date span for simulating worlds.

To avoid this issue altogether, I'm modifying the database keys to use two 64 bit values instead of one. With one of those values being used exclusively for dates. This will push the simulation time limit to 9,223,372,036,854,775,807 days, or 2.5e+16 years. This is such a huge limit, I could even introduce evolution and plate tectonic mechanics into the game. Not that I'm planning to do so... but I could, if I wanted.

So, yeah. I dedicated part of my weekend to this database revamp just so that I can generate better IDs for regions. I plan to spend a couple of extra days on it, but no more than that.

Download Worlds - History Simulator
Read comments (5)