-
Yeah, pure garbage. I'm sure everyone already knows that. I'm going to rearticulate a suggestion I made back when we were on the old board about fixing this.
To create that degree of randomness that's so useful in scripting, incorporate the dice command and output the value rolled to some $value ($dice). For example:
[code]
dice 1 d 100
if $dice <= 10
<whatever>
else
if $dice > 10
and $dice <= 30
<whatever>
else
if $dice > 30
and $dice <= 100
<whatever>
endif
endif
endif
[/code]
Here you have 3 possible outcomes, each with a separate probability of occuring. Since the dice command already exists, I hope that makes it a bit easier to incorporate into this functionality. It would certainly improve our scripting tools.
-
I think Nib's prolly the man to speak to about this. From a coder's perspective, there's an internal function dice() that takes an argument along the lines of dice(d+offset).
e.g
dice (20d6+10) would give you a min result of 10 + 20d6 = 30, max result 10 + 20d6 = 130.
The only problem I see with functions like these is of "striping", where the random factor isn't actually very random, making the randomisation a little "predictable", which is to say that in repeating the same function over and over and recording the results, definite patterns emerge in the data.
Linux provides a number of methods of providing much more random data, utilising things like entropy data extracted from the normal operation of the system, none of which are hard to implement. Indeed, there are external entropy packages we could employ for just this purpose.
In summary, I don't think it would be hard to give you a method of generating finite and bounded randomness based on defined probablility constraints. In fact, I'd be surprised if this hasn't already been addressed in the wealth of new functions Nib's bolted on recently.
Scott.
Scott.
-
Actually, I've got the source for the Mersenne Twister random number generator… which has a disgustingly long period for the random numbers, something about 2^19937-1\. I think that is enough. I'll slap that puppy into the code.
For your reading pleasure or if you are really interesting in this generator: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html