Dice Roller (#61)

Austin Z. a écrit :

How exactly would those d10s differ from a d100?

In the same way that 3d6 is different than rand(16)+3. It’s not
necessarily as dramatic a difference, but IME, the incidences of the
very lows (01-19) and very highs (81-00) are not as common as those in
the middle.

Not in that case ! Very simple : you have 100 possible values, ranging
from 1 to 100 … each value correspond to a single dice configuration
(it you rool 2 and 5 you get 25 and you have no other way to get 25).
Thus the probability of each value is 1/100 … and all values are
equiprobable !

And of course you can generalize the result ^^
You want a d1000 ? take 3 d10
You want a d36 ? take 2 d6 and calculate : 6*(d6-1) + d6
You want a d144 ? take 2 d12 : 12*(d12-1) + d12

Morus W. a écrit :

Do 5d5-4 rolls with 5d5-4 probably different dices having 16/d4 sides
(number of sides calculated for each roll individually) or should one
choose the number of sides once for all rolls?
I guess it doesn’t make much difference but it should be specified…

Morus

IMO, all the parenthesis must be resolved before going further.
Thus in the example you rool :
5d5
1d4
and the last one with the result of the two computations.

Otherwise, it would be impraticle to do that with real dices (mmmmhh
…)

Pierre

On Jan 6, 2006, at 6:17 PM, Jacob F. wrote:

Short clarification:

Actually, when rolled together, both dice are zero-based. The
double-nought is the only special combination of 00 -> 100. When
rolled singly, a d10 has 0 -> 10. Rolling a 0 is never possible.

Egad, I have been extra dumb today, haven’t I? I’m very sorry to
keep leading everyone astray. Jacob has it right here, not me.

James Edward G. II

On Sat, 07 Jan 2006 01:44:26 -0000, James Edward G. II
[email protected] wrote:

[snip involved dice discussion]

Honestly though, I won’t think less of you if you generate a random
number between 1 and 100. :slight_smile:

Phew :smiley:

If so, why is a 0 never possible?
And why does d10 have 0 -> 10 while a d6 has 1 -> 6?

For the purposes of this quiz, I propose that dice are 1-based. Which
means a d6 has six sides numbered 1, 2, 3, 4, 5 and 6 (ie, 1->6). A
d10 should be 1->10, not 0->10.

There is a bunch of discussion above talking about d10 variants, but
for simplicity, a N-sided die generates values from 1 to N inclusive.
That is, rand(N)+1.

Hehe, sorry, it’s too early. I’m just happy because I finally
finished a ruby quiz.

Cya in 40 hours or so… (and hope I’m really computing non-fubar’d
results… :slight_smile:

Regards,

Bill

Hi,

Just to make sure I have the precedence and so on right, I used a loaded
dice that always rolls it’s number of sides to write some tests. Since
there’s been some discussion over the precedence rules, I’ll post them
to
maybe compare with others and see if I’m on the right track. Hope that’s
within the rules? I’ve left out broken input ones, since at the moment
mine just ‘does it’s best’ but I might tighten that up yet…

 @asserts = {
   '1'                   => 1,
   '1+2'                 => 3,
   '1+3*4'               => 13,
   '1*2+4/8-1'           => 1,
   'd1'                  => 1,
   '1d1'                 => 1,
   'd10'                 => 10,
   '1d10'                => 10,
   '10d10'               => 100,
   'd3*2'                => 6,
   '5d6d7'               => 210,   # left assoc
   '2d3+8'               => 14,    # not 22
   '(2d(3+8))'           => 22,    # not 14
   'd3+d3'               => 6,
   'd2*2d4'              => 16,
   'd(2*2)+d4'           => 8,
   'd%'                  => 100,
   '2d%'                 => 200,
   '14+3*10d2'           => 74,
   '(5d5-4)d(16/d4)+3'   => 87,    #25d4 + 3
 }

Cheers.

Thank you all for pitching in your explanation of dice rollers to non-
D&D players like my self. However, there’s a considerable amount of
noise for this post (already) and I’m not 100% confident I could
parse the dice syntax in English let alone ruby. Would it be
possible to summarize this discussion and post it as an addendum at
Ruby Quiz - Dice Roller (#61) ?

~ ryan ~

On Jan 6, 2006, at 9:26 PM, J. Ryan S. wrote:

Thank you all for pitching in your explanation of dice rollers to
non-D&D players like my self. However, there’s a considerable
amount of noise for this post (already) and I’m not 100% confident
I could parse the dice syntax in English let alone ruby. Would it
be possible to summarize this discussion and post it as an addendum
at Ruby Quiz - Dice Roller (#61) ?

Feel free to summarize here, but I generally don’t add the discussion
to the quizzes themselves. I like to keep them pretty basic an we
can always go to the archives as needed, I figure.

I did correct the error on the site though. :slight_smile:

James Edward G. II

On Sat, 7 Jan 2006, Pierre Barbier de Reuille wrote:

Not in that case ! Very simple : you have 100 possible values, ranging
from 1 to 100 … each value correspond to a single dice configuration
(it you rool 2 and 5 you get 25 and you have no other way to get 25).
Thus the probability of each value is 1/100 … and all values are
equiprobable !

Wimps! REAL gamers roll 100 sided dice (aka Zoccihedron)

– Matt
Nothing great was ever accomplished without passion

The quiz shows incorrect output for 3d6. The line reading “72 64 113
33 78 82” was mistakenly copied from a different set of dice.

“3d6” means: (rand(6)+1) + (rand(6)+1) + (rand(6)+1)

(The +1 are because rand is zero-based, but dice are one-based.)

  • is subtraction, so -4 means subtract 4.

/ is division, so /d4 means roll a d4 and divide that into the
expression left of the /

d% == d100

d00 is not valid; there is no such thing as a zero-sided die (although
if you want to make 00 an extension to imply d100 in your own
implementation, that’s fine).

Resolve precedence before associativity.

So 1+2-3 == (1+2)-3 because + and - have the same precedence.

But 1+23 == 1+(23) because * has precedence over +.

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.

This dice roller is, for the most part, a simple integer calculator
with addition, subtraction, multiplication, division, and grouping via
parentheses. In order to turn it into a dice calculator, we add the
‘d’ (dice) binary operator. The required right argument to ‘d’ is the
number of sides on the die, while the option left argument (defaulting
to 1) is how many to roll and sum.

So 16 / d4 means “roll one 4-sided die and divide the result into 16”.

On Fri, 2006-01-06 at 23:45, Robert R. wrote:

Huhu.
How do you parse 5d6d7?
As (5d6)d7 or 5d(6d7) since there is no “Assoziativgesetz” like (AdB)dC
== Ad(BdC).

aTdHvAaNnKcSe

With the game systems I know, and I admit I haven’t played for a couple
of years, 5d6d7 would not be a legal expression, and would raise an
exception.

/Henrik

http://www.henrikmartensson.org/ - Reflections on software development

I’m not sure whether this made it to the list first time I sent it, or
is just delayed. Here it is again in case folks missed it…

I would appreciate the full BNF, please.

Okay, this is what I’ve done in my current version that takes care of
basic precedence and associativity.

INTEGER = /[1-9][0-9]*/

expr: fact
| expr ‘+’ fact
| expr ‘-’ fact

fact: term
| fact ‘*’ term
| fact ‘/’ term

term: unit
| [term] ‘d’ dice

dice: ‘%’
| unit

unit: ‘(’ expr ‘)’
| INTEGER

Actually, this is slightly different than my current version, which
after reexamining to extract this BNF, I found a minor error (in
handling of the term rules and handling of the optional arg). My own
code has a morphed version of this BNF in order to code up a recursive
descent parser, but this BNF shows one way to handle the
precedence/association rules.

“Ross B.” [email protected] writes:

 @asserts = {

   '(5d5-4)d(16/d4)+3'   => 87,    #25d4 + 3
 }

This is wrong, the maximum is 339: (25-4)d(16/1)+3.

On Sat, 07 Jan 2006 12:27:05 -0000, Christian N.
[email protected] wrote:

tighten that up yet…

 @asserts = {

   '(5d5-4)d(16/d4)+3'   => 87,    #25d4 + 3
 }

This is wrong, the maximum is 339: (25-4)d(16/1)+3.

Ross B. - [email protected]

I don’t understand that. I get:

(5d5-4)d(16/d4)+3		= 87
(5d5-4)d(16/d1)+3		= 339

I read the first as 21 rolls (25 - 4) of a four sided (16 / 4) dice plus
3, while the second is 21 rolls (25 - 4) of a 16 sided (16 / 1) dice,
plus
3.

Right?

Right?

(5d5-4)d(16/d4)+3

(5d5-4) is 25 at max
(16/d4) is 16 at max
25d16+3 is 339 at max

qed

“Matthew D Moss” [email protected] writes:

___ d ___ 4 16 ___ d ___
5 5 1 4

So what are the maximum and minimum values of this?

“Ross B.” [email protected] writes:

I’ll post them to maybe compare with others and see if I’m on the

Right?

Yeah. I got your list wrong then, I thought the number means the
maximum reachable, not what to throw with loaded dice. Sorry.