On Jan 6, 2006, at 12:56 PM, Ruby Quiz wrote:
>
> The task for this Ruby Quiz is to write a dice roller. You should  
> write a
> program that takes two arguments: a dice expression followed by the  
> number of
> times to roll it (being optional, with a default of 1). So to  
> calculate those
> stats for your AD&D character, you would do this:
>
> 	> roll.rb "3d6" 6
> 	72  64  113  33  78  82
>
Ok, I'm still a little confused. This should have output something like:

   rand(16)+3  rand(16)+3 rand(16)+3

> Or, for something more complicated:
>
> 	> roll.rb "(5d5-4)d(16/d4)+3"
> 	31

What is the -4 and the /d4 do?

Does the +3 apply to (5d5-4)d(16/d4) or to (16/d4) only, assuming it  
matters
since I don't know what this stuff does.

>
> A few more things...  Feel free to either craft this by hand or an  
> available
> lexing/parsing library.  Handling whitespace between integers and  
> operators is
> nice.  Some game systems use d100 quite often, and may abbreviate  
> it as "d%"
> (but note that '%' is only allowed immediately after a 'd').

So d100 == d% == d00

and

100 == 00

correct?