mercredi 30 décembre 2015

Converting an arbitrary seed into a float between 0 and 1

I want to be able to change any string containing any utf-8 into a random number between 0 and 1.

I can convert any seed that is a number with the following:

Math.abs(Math.sin(seed));

From this I'm able to generate a pseudo seeded Math.random()-like number.

So it's converting a string into a number. I looked into using crypto and found that making a digest of the string works but is incredibly slow, and is a bit overkill.

Any ideas on how to accomplish this?




Aucun commentaire:

Enregistrer un commentaire