samedi 4 mai 2019

Getting a random number, using a string

The field is fictional genealogy: I have a bunch of people with names and birth dates. They need death dates too, so I was going to generate numbers in a range (let's say 50 to 90), and assign them a death date that's that amount of years from their birth year.

Thing is, I will want to run my tool multiple times, adding and/or removing people for every iteration of the family tree, and my people should still get the same death years every time.

So what I want is a random number generator, that takes a string (the person's name), and always gives the same number when it is fed the same string. So, e.g., "John Johnson" will always be 67 years old when he dies, every time I run the tool.

I hope my idea makes sense? What's a good way to approach this? Is there a way to do this with weighted random number generators too? (e.g. so that a number between 65 and 80 is the most likely) The language is C#.




Aucun commentaire:

Enregistrer un commentaire