- Home /
Memory management with extreme amount of data
I am creating a universe with billions of galaxies. Each galaxy has billions of stars. Each star has its own set of planets and other orbiting objects, each planet having their own characteristics (mineral and atmospheric makeup, orbits, moons, possible lifeforms, etc.)
However to even have a one dimensional array tracking just the name (in floats) of 1 billion systems:
1 billion elements * 8 bytes per float = 7.45 gigabytes of memory
So unless I am missing something pretty fundamental this is impossible. The only possibility I can think of is not having the entire universe loaded into memory, but loading the local area that the player is working on into memory from a file. I don't have much experience with this kind of structure. There would be an awful lot of reading from file, loading it into memory, making the changes, then overwriting the source data, loading entirely new section of data, wash rinse repeat. As far as the visual aspect of it, I was just planning on having the thing that the player is working on visible, so there would be very little requirements there.
Is this a bad idea? Are there any examples of games that deal with such extreme amounts of data or is it just outside the boundaries of whats possible?
Answer by DamienSturdy · Apr 16, 2012 at 01:18 PM
I think you may be approaching this from the wrong angle. What you are looking for may be something more like Elite, where the entire system is generated randomly. It's based on a fixed Seed so the generated systems are reproducable, but then you have functions that, instead of reading an array or a file, return a random value.
It's a little more complex than what I'm saying but this is probably how you should approach it. It'll reduce your dataset massively.
Thank you for the response. Im not sure that would solve my problem. There will be a lot of things going on outside of the player's view. For example, intelligent life in a distant galaxy that player may not contact until very late in the game. Over the course of the game the computer player has been developing as a species. Wouldn't this require that all of this was created at the beginning, and not the result of a random value generated? The computer would have to know there is an AI at this location that will be acting?
It probably doesn't sound like this comment is making much sense, I will take a look at Elite. I hadn't considered using a seed and I like the idea of being able to reproduce games.
It sounds very much like you are wanting to script various aspects of the gameplay. Which would mean that you can't use a randomly generated universe either.
I would suggest that maybe you need to rethink your requirement to have 'billions' of star/galaxies etc. Even with just 1000 stars, how long would your player have to be playing to visit them all? Realistically how long do you think a player will play before they get bored?
I'd maybe focus on having a few cleverly scripted, interesting places to visit that mean that you can look forward to some meaningful progression.
It sounds a little like you are creating a maze, with no end, that you expect to keep people interested?
Answer by DamienSturdy · Apr 17, 2012 at 11:34 AM
You can still random generate if you are scripting. You'd need to be very careful with your random gen code, but you'd have a stable system afterwards. This said, you would need to script your game around the generated system. Developing species is more of a story thing- don't expect to create an AI that genuinely develops itself whilst the player gets through the story.
OR, Create your "Fixed" parts of the system, and Randomly generate the rest- the parts where no story happens.
FOr positioning AI that "moves" with time- You should perhals invoke the random generator in such a way that at X universal time, the AI is at random place, but at Y Universal time (which should be significantly after X), the AI is at - for all times in between, use a bit of tweening to get a position between these two points. This way the AI will appear to move between points as time progresses, without you needing to worry about their actual position.
Good luck.