How many world seeds are in Minecraft?
There are 18,446,744,073,709,551,616 (264) possible seeds. All seeds are a number, if letters are entered into the seed box, Java's hashCode()
function is used to turn it into a number.
Seeds do not use up much disk space (stored as a long integer, meaning just 8 bytes per world) because only a seed that has been chosen for a world is stored; not all 18 quintillion. When a seed is needed for world generation, a random one is generated from the system clock (or entered manually by the user) and is then stored and used to generate the world.
How many possible worlds can generate, including customization options? Probably more than any computer can calculate given all of the float sliders available in a customized world.
Here's an image showing a randomly generated seed:
-3,010,441,696,458,036,422 is far lower than both -2,147,483,648 and -140,737,488,355,328. This means that seeds use higher than 32 bit and 48 bit signed integer ranges.
I originally stated that Minecraft uses Java's default Random
class for pseudo-random number generation. Random
uses 48-bit seeds.
However, that would imply that the seeds 1 and 248+1 result in the same world, which others have pointed out is not true. So I did some more digging.
Minecraft appears to use Random
everywhere except for the biome-generation code. There, it uses its own homespun random generator. From GenLayer.java:
protected int nextInt(int upperBound)
{
int randVal = (int)((this.chunkSeed >> 24) % (long)upperBound);
if (randVal < 0)
{
randVal += upperBound;
}
this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L;
this.chunkSeed += this.worldGenSeed;
return randVal;
}
This is a linear congruential generator with values a = 6364136223846793005
and m = 1442695040888963407
. This will indeed produce 264 distinct output streams, and thus there are 264 distinct worlds.
The claim on the Minecraft wiki that "Multiplayer seeds may only have 248 possible values [..] due to using Random.nextLong()
" is incorrect. The single-player and multiplayer world generators are not different.
The use of Random
everywhere else does mean that some things will be the same between seeds that are off by 248, such as seeds 1 and 248+1. For example, the location of ores should be almost the same between the two (except for ores removed by cave-systems).
Also, the use of per-chunk seeds has some interesting consequences. For example, given the small number of biomes and the large number of chunks, in any given world there is a very high probability that there are two chunks which are exactly the same. Finding those chunks, however, involves math which is beyond me. If anyone is interested in figuring it out, the code for initializing the chunkSeed
is
public void initChunkSeed(long chunkX, long chunkY)
{
this.chunkSeed = this.worldGenSeed;
for(int i = 0; i < 2; i++)
{
this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L;
this.chunkSeed += chunkX;
this.chunkSeed *= this.chunkSeed * 6364136223846793005L + 1442695040888963407L;
this.chunkSeed += chunkY;
}
}
So the answer is found here: http://minecraft.gamepedia.com/Seed_(level_generation)
Which even though it's already linked on this page no one seems to have read it all.
To summarize:
If you use a word or phrase then String.hashCode()
is called and it limits your maximum amount of seeds to 2^32 because of it's implementation.
If you enter your own number or let the system determine the seed then your seed limit is 2^64 seeds.
HOWEVER:
If it's a multiplayer world they implement the nextLong()
java function and the limitations of that are 2^48 possible seed options.
Seeds are hashed into a 32 bit signed integer. Which is programmer speak for a number that can be positive or negative, and is 32 values in base 2.
This gives the numbers from -2,147,483,648 to 2,147,483,647.
Depending on the implementation of Minecraft some of those might result in the same world in certain aspects like having 2 seeds with different biomes but the same heightmap.
(Partial) correction: If you don't set a text seed minecraft will instead take the current time as it's value, which is a 64 bit number so there are more options there.
Source: http://minecraft.gamepedia.com/Seed_(level_generation)