# Is it possible to find a seed based on 10,000 generated random numbers?

I'm currently entertaining an idea I've had about procedurally generating a world. I would like the entire world to be procedurally generated on the fly. So when a chunk is loaded, it uses a seeded random number generator to create the terrain and objects. It is seeded to maintain persistence. This is nothing new.

Next, I want the player to be able to come in and manipulate the environment (destroy blocks, place blocks; I'm using a minecraft type recreation right now to test the idea because the blocky environment is simple to work with). If we simply used a seeded random number generator, the player's changes would get overwritten once the chunk is discarded and reloaded. So what if we use the new block locations in the scene to generate a seed for a random number generator that will generate the environment. We know the exact order that it will generate blocks, so each time a number will be generated, we know what that number should be. I've looked around the cybersecurity forums a bit but haven't found a good explanation of retrieving seeds given ordered generated numbers. If this works you could save a large scene in only the seed it takes to generate it.

Please let me know if this idea is stupid and should be thrown away, thanks!

Please let me know if this idea is stupid and should be thrown away, thanks!

This idea is [ill-founded] and should be thrown away.

And we can prove it with a little math!

Let's say your seed is a 64-bit integer. That means it can hold one of $$\2^{64}\$$ values.

That means that you can describe, at most, $$\2^{64}\$$ different worlds by specifying a seed. "At most," because your generator might produce identical outputs for two different values — say if your RNG function has a collision (two internal states that yield the same observable output), or if you round a value somewhere, wrap/truncate it, or use non-uniform probability to give some features a greater chance of occurring.

From this seed you're generating 10 000 blocks. Let's say each one can be specified by a single byte. The number of possible 10K block worlds that can be built in this way is $$\8^{10 000} = 2^{30 000}\$$.

There are vastly more worlds that can be produced by editing block-by-block than can ever be created by your generator acting on your seed.

So there are things your player can do to your worlds that take them outside the expressive range of your generator, and no possible seed could replicate it, even if you had a fast way to check every seed.

• Alright great answer, back to the drawing board! – Joe Fioti Jan 30 '20 at 2:37
• You can still get decent compression by storing only the difference between the modified chunk and the generated one - this will almost always be tiny compared to the full chunk, and often much more compressible too, since players often make changes that exhibit a pattern, like hollowing out a large area with explosives, or building structures in straight lines. – DMGregory Jan 30 '20 at 2:39
• True, but I was thinking of building a world on the magnitude of a planet or bigger. Eventually I'd like to build a fully procedural space game, and so all of the changes made by all of the players would be way too much to store after a while of allowing the players to build bases, etc. – Joe Fioti Jan 30 '20 at 2:41
• That sounds like a question worth asking on its own. "How can I persist player changes to the environment in a procedural space game?" – DMGregory Jan 30 '20 at 2:44
• @JoeFioti How many changes do you think a player can make per second? How many seconds will they be playing your game? How many players will there be? Think about the average Minecraft base, then think about how long it took to get that way, then think about how much data it would take to store. – user253751 Jan 30 '20 at 16:56