Can two different seeds produce identical worlds? Yes - at least partially

So, intrigued by a post in this thread, I decided to look into this myself; I thought about posting this in that thread but decided my findings were significant enough for a new thread, plus that one is a bit old and outdated:

Here's some fun...
9223372036854775807 is the same world as
6444932541743890431

Judging by your post, I think you can figure out why... :smile.gif:

While it is no longer true that these seeds produce identical worlds, this only appears to apply for the most basic terrain/biome generation steps; all other features, unless biome-dependent, will be exactly the same between otherwise different worlds, greatly reducing the number of possible seeds with certain unique features. To be specific, Java's Random class only uses 48 out of 64 possible bits when a seed is used, which limits the number of unique seeds to 2^48 or about 281 trillion - that is an incredibly huge number but nowhere near as large as the full number of unique seeds possible from a true 64 bit seed; 2^64 or 18.4 quintillion (NB - the first seed given above is the maximum positive value of a 64 bit signed integer). This is also the random number generator used for most world generation, except for the land/ocean and biome generation stages, possibly even only the former, for which the game uses its own 64 bit random number generator, completely independent from Java's Random class (which can be overridden to use a 64 bit seed but none of the methods that use it do so, they just directly call the setSeed() method). This means that there are 65,536 seeds (2^16, with bits 1-48 staying the same but bits 49-64 variable) that will result in the same sequence of random numbers.

This is reflected in world generation with some features being exactly the same in otherwise different worlds, particularly those that are independent of biomes, as the following two worlds I created in 1.8 using the seeds provided above show:

Seed: 9223372036854775807:

Seed: 6444932541743890431:

Besides the very obviously identical caves, ravines, and mineshafts (these are also independent of world type), you can even see some of the same lakes and hills; for example, look to the north of my position on each surface map; you can see several lakes and hills that are exactly the same in both seeds. A few minor details like the locations of ores and water/lava springs are different but is due to the different biomes; one small change will cascade down through the line as only one random number generator is used to generate minor features like trees, ores, lakes, etc but caves and major structures use their own independently seeded RNGs.

Here is an even bigger surprise, using the seed for my 1.6.4 world and another seed with several bits added (for easy generation of such seeds I used this calculator, adding 1s and 0s to the leftmost end of the binary representation after plugging in the decimal value):

Seed: -123775873255737467

Seed: -556121437483305083

The villages, chest contents, and immediate surrounding terrain are exactly the same - down to the tall grass! I suspect there are many other seeds with the exact same village and terrain as well - as mentioned above there are 65,536 seeds that could have the same village, provided the biome is the same (the villages are located at 360, 120). This is less likely to occur in 1.7 and later due to the additional biomes but is still very possible.

Also, here is a look at four such seeds with the same "base" seed value (the same one as my world, again in 1.6.4 but any version will work), centered around the first world's spawn point (-92, 236); note that I again only added extra 1s and 0s to the end but you could also subtract them since the base value is larger than 48 bits in size:

Seed: -123775873255737467

Seed: -267891061331593339

Seed: -412006249407449211

Seed: -556121437483305083

Once again, you can see that the underground is identical, save for caves that cut off due to water in the third example in particular; this also crushes myths that caves/mineshafts/etc are more common in a particular biome, as the Wiki even claims for Extreme Hills; "More underground cave systems are present here than in any other biome.", which is only slightly true; more mountains does mean some more caves above sea level but the majority of caves are well below sea level with the frequency peaking near bedrock, and no more caves actually generate otherwise.

Not only that, note that three of the seeds have a large lake to the southwest of my position; the details vary but you can readily see that they are the same lake; the differences only appear to be due to the height differences of the different biomes it is in; the last seed also has a village in it similar to the first seed, likely only different because the biome is different but otherwise in the same location. Even more so, check out the rivers and the outlines of some biomes in the same three seeds, particularly the first and last ones - it seems like the shape of biomes is limited by the 48 bit limitation even as biomes themselves aren't and that might only reflect the different landmasses; indeed, a look at AMIDST appears to confirm this - note the identical shapes of the desert and swamp biomes respectively to the east of the first world's spawn, you can see some other biomes that have the same shapes as well though the mix of biomes and different landmasses makes it hard to make them out; the similarity in rivers is easier to see:

So in summary, the only aspect of world generation that appears to make full use of a 64 bit seed is the generation of landmasses/oceans, possibly also biome placement but differences there are likely due to the changes in landmasses, similar to how biomes affect minor details in otherwise identical terrain. The big question is - why did they decide to forgo Java's Random for only a few (one?) specific features, or not just use Random for everything? It may have more to do with how it is used, as seen in the GenLayer class, rather than the 48 bit limitation (it seems to break up the RNG into three variables, "baseSeed", "worldGenSeed", and "chunkSeed", and do different things with them).

Another thing that is interesting is that terrain features in default, large biomes, and customized worlds will be identical if the biome at a given coordinate is the same (for customized, if just making the world one biome or changing biome size), due to only biomes being enlarged, not terrain features themselves, which are only dependent on the world seed and chunk coordinates, and biomes in some cases.

So, what does this mean from a practical standpoint? Well, not much since there are still at least 281 trillion unique seeds depending on which features you are looking for; it can come in handy though if you found a seed with a big cave system but under an ocean biome, or perhaps you found a nice village but wanted different biomes around it, and so on. - just change the upper 16 bits and you'll eventually get a seed that has it on dry land and/or with whatever biomes you want.

Also, there is at least one feature that isn't affected by the world seed and is the same for every world; bedrock always has the same pattern, as mentioned here and confirmed by looking at the code (Overworld and Nether, if not identical between dimensions due to the latter generating two layers).

I used Unmined; specifically, the older version (0.3.165) as it shows caves better than the new (development) version (for best visibility turn off "cave edges" and "dark underground"). Note that it still works even on 1.8 worlds but new blocks are shown in gray (not an issue when looking underground).

(I'm assuming you are talking about the maps showing caves, as I see you used AMIDST in this thread)

I went and turned biome offset off for your first two of four, and these were the results:

The basic terrain is exactly the same, including the generated water lakes, the large one in the center, and the one on the right. Also, the terrain in the bottom-left is exactly the same because they are Extreme Hills + in both worlds. However, liquid springs generated in different places and the spawn was different in both worlds.

However, liquid springs generated in different places and the spawn was different in both worlds.

I must say that is a bit odd unless the biomes were different, since the order of decoration is water lakes, ores, then trees and other mostly biome-specific features, then water/lava springs, so any changes to trees and other biome-specific features due to the biome being different will affect the generation of springs. They should be the same in the Extreme Hills+ area. Note also that since ores generate before most other features (but after lakes) changing ore generation will change their positions, including ores that generate afterwards (the order in the code is the same as in the customized settings). Also, villages prevent lakes from generating, which will similarly have downstream effects (as far as I can tell the placement of villages wasn't changed between 1.6.4-1.7+, so there should be a seed based on the one that I gave that has a village in the same location as in 1.6.4).

As for the world spawn point, the placement of biomes affects it since only a few biomes are "valid" spawn biomes, which has actually been unchanged since 1.6.4 (plains, forest, jungle, regular taigas, and the -hills variants of these, are all "valid"; if the game can't find one of these within a certain distance of the origin it will start to randomly check up to 1,000 chunks for exposed grass blocks, sometimes spawning you over 1,000 blocks away from the origin by the time it stops; this is to try avoiding spawning players in deserts, oceans, etc). Another feature that is affected by biomes are strongholds; the game excludes biomes with a "minHeight" of 0 or less, which includes, oceans, rivers, and swamps and does a similar check as with player spawning; it appears though that the relative angles remain the same (uses Random to get a random number between 0 and 2*pi to set the angle).

Also, it is particularly interesting how the terrain so closely resembles that from 1.6.4, such as the large lake near the center; I'd have thought it would be significantly different; for one, terrain can go all the way to the world height limit instead of flattening out just below y=128, so they must have changed something in the code, but without any effect on local height variation.

I went and turned biome offset off for your first two of four, and these were the results:

The basic terrain is exactly the same, including the generated water lakes, the large one in the center, and the one on the right. Also, the terrain in the bottom-left is exactly the same because they are Extreme Hills + in both worlds. However, liquid springs generated in different places and the spawn was different in both worlds.

Wow... that's interesting. Maybe we could do the same thing with the Beta 1.7 gargamel seed

Also, it is particularly interesting how the terrain so closely resembles that from 1.6.4, such as the large lake near the center; I'd have thought it would be significantly different; for one, terrain can go all the way to the world height limit instead of flattening out just below y=128, so they must have changed something in the code, but without any effect on local height variation.

The current generator (and the 1.6.4) is basically the (bugfixed) Beta generator, but extremely flattened. Changing the upper/lower limit scales will bring out Beta terrain features. So, really, the terrain generation hasn't changed all that much since Beta -- just the biomes.

The current generator (and the 1.6.4) is basically the (bugfixed) Beta generator, but extremely flattened. Changing the upper/lower limit scales will bring out Beta terrain features. So, really, the terrain generation hasn't changed all that much since Beta -- just the biomes.

According to this thread the limit scales were the same back in Beta as now, only the addition of "biome height" variables is; when I increased height variation in my mod I basically made "normal" biomes have the same "maxHeight" (as seen in the MCP source) as x-hills biomes, which in turn have a higher value; if I had to guess, a maxHeight of 1.0 results in no height scaling from what Beta had (I set it to 0.8 for most biomes; for comparison, Extreme Hills has a value of 1.5 in 1.6.4 with plains, forest and desert set to 0.3).

Also, one potential issue with simply increasing height variation of all biomes is that some biomes are better left alone, and biomes with villages shouldn't have too much variation (I added variations of plains and deserts with increased height variation; to prevent villages (only generating in the regular biomes) from becoming rarer I reduced their max distance and have regular plains/deserts generate as sub-biomes inside their hillier counterparts).

According to this thread the limit scales were the same back in Beta as now, only the addition of "biome height" variables is; when I increased height variation in my mod I basically made "normal" biomes have the same "maxHeight" (as seen in the MCP source) as x-hills biomes, which in turn have a higher value; if I had to guess, a maxHeight of 1.0 results in no height scaling from what Beta had (I set it to 0.8 for most biomes; for comparison, Extreme Hills has a value of 1.5 in 1.6.4 with plains, forest and desert set to 0.3).

Also, one potential issue with simply increasing height variation of all biomes is that some biomes are better left alone, and biomes with villages shouldn't have too much variation (I added variations of plains and deserts with increased height variation; to prevent villages (only generating in the regular biomes) from becoming rarer I reduced their max distance and have regular plains/deserts generate as sub-biomes inside their hillier counterparts).

I've read that too, and it's probably correct, but changing the limit scales does make the terrain more Beta-like -- arguably more so than the neo-beta preset as seen in this one: