mercredi 23 septembre 2015

random values with uneven distribution

Implementing Hangman. I want to randomly select the length of the word, taking into account how many words of a given length are in the wordlist - ie. 12-letter words should be chosen less frequently than 5-letter ones, because there are fewer of the former.

It doesn't look like the random module will do that easily.

I could hack something semi-ugly together, but am looking for suggestions of a tidy way to do it.




Aucun commentaire:

Enregistrer un commentaire