Obviously, you roll 1.5 dice. Or 1.2 dice. The sub below allows you to roll any positive number (*) of dice. I've included a little wrapper program so you can see the distribution of results of 50000 throws.
The parameters are, in order: lowest value to return (integer), number of distinct possible return values (integer), how many dice to use.
* numbers smaller than 1 all act like 1
my $range=12; my $low_end=6; my $dice=1.2; my %freq = (); for (1..50000) { $freq{ roll_dice($low_end, $range, $dice) }++ } print "$_: $freq{$_}\n" for sort {$a<=>$b} keys %freq; sub roll_dice { my ($low_end, $range, $dice) = @_; my $result = 0; my $i; for ($i = $dice; $i >=1; --$i) { $result += rand($range); } $result += rand($range) * $i; int($low_end) + int($result/$dice); }
In reply to Fractional dice by Roy Johnson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |