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

1.15K 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

Actual ELI5:

Imagine you are in a street corner in your city.

You always go forward 2 blocks, then 2 left, then 2 forward again.

If you do the same path from a different corner, you will end up in a different place.

If you go back to the first corner, you will end up in the same place as before.

The corner is the seed, your movement (2 up, 2 left, 2up) is the algorithm, which is fixed, the same one is used in your and your friends computer.

This is why the same seed ends up generating the same world.

Anonymous 0 Comments

True randomness doesn’t exist in computer software and games, it’s just a trick that generates numbers that appears to be random, so it’s pseudo-random.

Computers generate random stuff by getting a seed, which is any number stored inside the program or picked elsewhere (like the system time in miliseconds) and then from this number you can get the randomness efect by myltiplying it with another number, adding other number… Something already coded inside the game. That’s why its called “seeds”, because from it you can generate other random values.

In minecraft, the game uses the seed to create the world. For example, if you code an algorithm that places a nether portal inside the world like:

x = seed * 5 -23

y = seed * 25 + 7

Notice that if you use the seed “10” the portal will be generated exactly at x: 27 y: 257. Notice that the numbers seems like are random but you can always get the same if you use the same seed. If you use another number like 11 it changes the numbers completely: x: 32 y: 282. This is a small example and minecraft algorithms are much more complex.

How minecraft automatically generates the seed number? Simple, if you leave the seed blank, the game just “tells the computer” to give any pseudorandom number that uses another but similar method.

Anonymous 0 Comments

Someone will make a formula that takes a number and makes a new one.

Here’s a silly one I’ll make up for example.

Take a number to start with, 506. That’s the seed for the formula. Reverse it so you get 605. Multiply those together. 306,130.

Just use the first three digits, since my formula only cares about three digit numbers. 306 is the new number.

Now I can make another number from 306.

306×603=184,518

And I can keep going…

184×481=88,504

885×588=520,380

520×025=13,000

If I use the same formula and same seed number 506, I’ll always get 506, 306, 184, 885, 520, 130…

If I use a different seed number, like 222, I’ll get… 222, 492, 144, 635, 340, 146…

A good formula can make numbers that are random enough, while still following a pattern that’s difficult to work out