in reply to Rolling DND Dice.
If you don't want to think too hard, you can find the expected value experimentally -- Just do a million (or so) status rolls see what the average is. Note the array-slice of the sort, which finds the 3 highest dice with much less mucky-muck.
For a million iterations, I got an expected value of 12.244657, which is within 0.0005% of your exact answer.use List::Util 'sum'; my ($iter, $sum) = shift || 1_000_000; $sum += sum +(sort map {1 + int rand 6} 1..4)[1..3] for 1..$iter; print $sum/$iter, $/;
You could also use some of the Die/Dice modules on CPAN, but rolling (fair) dice is pretty trivial to do yourself.
blokhead
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Rolling DND Dice.
by grendelkhan (Sexton) on Feb 04, 2004 at 03:08 UTC | |
by blokhead (Monsignor) on Feb 04, 2004 at 04:27 UTC |