Hopson97 / open-builder

Open "Minecraft-like" game with multiplayer support and Lua scripting support for the both client and server
https://github.com/Hopson97/open-builder/projects/3
GNU General Public License v3.0
703 stars 80 forks source link

Added support for string seeds using hashing #98

Closed rehwinkel closed 4 years ago

rehwinkel commented 4 years ago

The seed is used as an offset for x and y axis and also used as the 3rd parameter to the simplex noise. Also, the seed is an given as an integer, which is then reinterpreted as a float before being used. This integer can be generated from a string using md5 hash. The default seed has been set to "test"

b0guslaw commented 4 years ago

While I agree with the intent to generate a seed from string using a hashing function, I believe MD5 is entirely overkill for this purpose since the generated hash does not need to be secure in the cryptographic sense of the word. I suggest to keep the PRs intent, but swap out MD5 for std::hash, which should also provide a small performance benefit on the side.

rehwinkel commented 4 years ago

@b0guslaw good suggestion! MD5 was the first thing that came to my mind, so I used that, but std::hash seems so much more convenient!

rehwinkel commented 4 years ago

Apparently using the seed from std::hash generates the same terrain as using md5.