How does seed generation work in a video game?

360 views

How does a random string of characters, or in the case of some games (Rimworld) manage to generate a whole world with a single word?

In: 6

4 Answers

Anonymous 0 Comments

When the world is being generated, the game has to make lots of decisions. What goes in this tile? Where does the player start? Is there an enemy here? Etc.

It usually makes these decisions at random. If there’s a 5% chance an enemy can be on any tile, then generate a random number from 1-100 and make an enemy if the number is 5 or less. (Actual open world generation is much more complicated because a random amalgamation of tiles and stuff doesn’t feel like a “world,” but the relationship to random numbers is essentially the same)

The thing with computers is that they are not really capable of randomness, so they simulate it. (Pseudo) random number generators can take a number and give out a number that appears random, but it’s really just the old number put through a bunch of mathematical functions. To generate another number, it just takes the last one and puts it through again, and so on forever.

The ‘seed’ in this process is the very first number the generator uses. If you repeat the process with the same seed, every “random” number generated will be exactly the same as it was before. Therefore every choice is the same, and the final world is the same. This can be a problem in other applications, but for games its just fine, because (as you’ve noted) it gives players a compact way (just the seed number) of sharing worlds they like or find notable.

You are viewing 1 out of 4 answers, click here to view all answers.