the formula:
4d6, discard 1s and add the three highest rolls. Do this six times.
yup pretty standard D&D ability rolls :)
So here's the questions:
using
#! /usr/local/bin/perl
use warnings ;
use strict ;
#Die Roller: uses 4d6 discarding the lowest number
#rerolling any roll of 1
my $roll = 6 ;
until ($roll == 0) {
chomp $roll ;
$roll -- ;
my $d61 = int(rand(6) + 1) ;
my $d62 = int(rand(6) + 1) ;
my $d63 = int(rand(6) + 1) ;
my $d64 = int(rand(6) + 1) ;
print "$d61, $d62, $d63, $d64\n\n" ;
}
I get output like:
5, 2, 5, 4
4, 3, 6, 4
3, 6, 4, 5
5, 1, 2, 3
6, 5, 5, 2
2, 6, 5, 1
OK so I'll use an
if/else statment to reroll the 1s (does that sound reasonabe?) but how do I figure out and discard the lowest number?
--
ellem@optonline.net
There's more than one way to do it, just don't use my way.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.