01-20-2010 01:13 AM - edited 01-20-2010 01:21 AM
For a Random Interger from 1 to 5 you do something like this:
Edit: I just realised, that the chances for every Number are not the same, so my version is kind of unusable for statistically correct purposes.
Its too early in the morning
Edit2: Also I realise further, that my version won't output 1-5 but 0-5 so it is not even what you wanted. D**n what did I do
01-20-2010 01:38 AM - edited 01-20-2010 01:39 AM
What does the I32 do exactly?
"To I32" converts your floating point number to an integer, as you specified in your first post as requirement.
Here' a version that gives all 5 numbers with equal probability. Instead of explicitely converting to I32, I use the output configuration of the +1. Same difference.
01-20-2010 02:23 AM
01-20-2010 07:16 AM
No aestet, Altenbachs solution is perfectly fine.
The dice generate a Number between 0 and 1 (Not including 1!!) Multiplied by 5 that is a Number between 0 and 4.999999.
The next triangle always rounds the Number down, so that you can only get 0,1,2,3 and 4 everything with equal propablity.
Plus one you get 1,2,3,4 and 5.