how do “seeds” work in video games such as Minecraft?

358 viewsOtherTechnology

For example, how does an infinitely randomized world like Minecraft manage to generate me an identical world to my friend with just a handful of numbers that they send me?

In: Technology

23 Answers

Anonymous 0 Comments

It’s not infinitely random. It’s random from a set starting point. Every “randomization” algorithm used in the game will generate the same result IF it’s starting from the same starting point.

The seed is that starting point.

Edit: I say every one in the game. All the ones used for building the world are working off of that seed. Other things can be used as a seed, like say a hash of the system time reported into the game. There are algorithms in minecraft using other seeds like what blocks get hit with random ticks. Those won’t be identical between worlds.

Anonymous 0 Comments

Imagine your computer contains a giant list of random numbers from 0 to 1. Something like

0.287556474

0.784672058

0.045789234

0.572198849

0.519884387

And it goes on for millions of numbers. This list is static and the same for every copy of Minecraft.

When Minecraft is generating a world, it goes (this is an invented super-simple version):

* Check the first number – multiply it by 200 – that’s the size of our first biome

* Check the second number – multiply it by 20, and set the biome based on 1=Desert, 2=Forest, 3=Field, etc

* Check the next 1500 numbers, use those for altitudes within the biome

* etc etc etc

And it goes through this process for many many steps until a world is generated.

What the seed tells you is which number, in that massive list, is the “first number.” So if your seed is 1000000, then you start with the 1000000th number, and that number picks your first biome as per the steps above. Then the 1000001st number picks the type, and we continue through the list of instructions.

So if two players input the same seed, they will use the exact same numbers to generate a world and will wind up with the same world.

Anonymous 0 Comments

Because it’s not random it’s pseudorandom.

A pseusorandom number generator starts from any number (the seed) and then does a bunch of math operations that create a random looking number, but since the operations are clearly defined the outcome is also clearly defined.

For example, take any 3 digit number, multiply it with pi and then take only the 7th to 9th behind the decimal repeat this 5 times. The outcome will look completely random, but it will always be the same when you take the same starting number.

Minecraft now uses that to generate the world. Whenever a random decision is made you ask your pseudorandom number generator to generate a decision. In minecraft the coordinates of the world are also used plus the seed, so that the world looks different in different positions. For example “add a tree if seed plus x coordinate plus coordinare input into the random number generator starts with a 5”

Anonymous 0 Comments

Most random number generators on a computer aren’t really random. Instead, they generate a sequence of numbers that *looks* random, by picking a starting value and doing math to it. That starting value is the seed.

Usually, you want your random numbers to be different every time, so you use a value that changes naturally as the seed, like the current time. When you want to generate the same sequence of ‘random’ numbers, you can provide the random number generator with a seed. The math starts in the same place, so it generates the same series of numbers.

Then, when Minecraft generates a world, all it has to do is make sure it does the random world generation steps in the same order every time: that way, the same sequence of random numbers turns into the same world output.

Anonymous 0 Comments

Getting a random value out of a computer is basically impossible as they are deterministic machines and there is no real random algorithm. Those algorithms that create “random” numbers take an input value and perform some mathematical operations based on that input so that the value they output LOOKS random. That input value is what we call seed. To improve level of randomness it is possible to use factors for the input value that appear to be random to the algorithm (and user) such as mouse position/movements, cpu temperature etc.

Anonymous 0 Comments

A computer is really, really, really bad ad making random numbers (worse than humans!). As a result, when you ask a computer for a random number, then it takes some input, does a lot of maths on it, and returns a result from it. So it stands to reason that if you use the same input number, you get the same result. It is that input number that is called the seed number, or just seed.

What this means for Minecraft, is that when the random number generator is seeded with a particular number, it will always give the same world. This is handy because then you can find a “perfect” world where you can find diamonds easily (I don’t know, I don’t play Minecraft).

Anonymous 0 Comments

Speaking to Minecraft in particular.

Minecraft uses a type of randomness called *Perlin noise*. If you google *Perlin noise* you will get a bunch of images that look like black and white clouds. If you zoom way out on a Perlin noise image, you can begin to see a minecraft map as seen from above. This is how Minecraft generates its world. Based on the white/black ratio of these noise images. White could be ocean, light grey is grasslands, and black is mountains. This is oversimplifying a LOT.

The “Seed number” is what is used to generate the initial Perlin noise image for the world generator. The world generator runs the exact same way every time if no variables are changed. The “Starting point” the generator uses is the “Seed Number”. So if the world generator algorithm is the same between Minecraft versions, and you share a seed with a friend, both of you will generate the exact same Perlin noise map, and thus, the exact same world.

Anonymous 0 Comments

I saw a lot of answers here that address what a seed is and what “random” means in terms of the world of computers and these are all good answers. However, I wanted to give a bit of a game development perspective.

What Minecraft does is Procedural Generation, which means there is a set of instructions that use some input to generate some parts of the world. So there are some general guidelines that the game uses around biomes and what can be in those biomes as well as under/around that kind of make Minecraft worlds what they are. It uses this seed (random or not) to make these decisions.

To make it overly simplified. If your seed is “1234” then there may be a procedural step in where to start the desert biome, because the seed is 1234 the biome starts in a particular place, but if it were “1235” it would be completely different. It does this for every decision, where to place mobs/trees/water/minerals almost everything, and it procedurally narrows this down using this seed number to make these decisions. That’s why the world can be the same using the same seed, but you can’t manipulate the seed to make minute changes. And that’s also why it feels so “random.”

Short version, there is a set of rules that generate the world. It uses the random “seed” to make all the decisions to generate it. The rules and steps are always the same, but the seed is what changes and makes things random. This also allows the same seed to have the same outcome.

Anonymous 0 Comments

Generally speaking, there’s no such thing as “random” when it comes to a computer. They are fully deterministic machines. If you write a fixed algorithm and give it a fixed input, it will always return the same output. If you do need a truly random number, then it always needs to be fetched from *outside* the computer in some way (say by measuring background noise, the movement of your mouse, the CPU’s temperature fluctuations, radioactive decay, or many other ways).

In applications that aren’t security critical, computers will often use numbers that are “pseudorandom”. That means you take a seed number – say the current time – and apply a bunch of mathematical calculations on it to get a series of new numbers. It’s important to note that they aren’t really random. If you know the initial value, you can always apply the same calculations to get the same output numbers every time.

Video games use this trick during world generation. You start from a single seed (which could be random or not) and then generate every subsequent “random” number from that seed. So, if you know the seed and the exact algorithm, the entire world can be duplicated.

Anonymous 0 Comments

Pretend you have a deck of cards. You shuffle them up so they are no longer in order. Well, they do have an order, but it’s kind of random. As long as you don’t shuffle them again, no matter how many times you flip through the cards, you will get the same order. We’ll call this seed zero.

Now pretend you then take the top card, and put it at the bottom. The cards are still in the same order, you’re just starting in a different spot. This is seed one.

Move another card from the top to the bottom. Again, same order, but you’re now starting at seed two. You can continue to move cards the same way until you get back to the original one on top, and seed zero again.

Computers work the same way. They don’t have random numbers, the have math. But the math is always the same. So when you give it the number 0.37991, you will always get the number 0.61837 as a result (numbers made up). If you then use 0.61837 you then get 0 91826 as a result. So if you keep using the result as the input for the next calculation, you can create a list of numbers.

The seed is then the number you start with. Mincraft then uses that list, starting with that seed number, to create the world.