Dice notation

Asmor

First Post
Sadly, everyone's Dear Aunt Sally doesn't have much say as to the order of precedence of the 'd' in dice notation.

In the case of addition and subtract, it's obvious... 1d4+3 means (1d4)+3.

However, what about 1d4*3? Should that mean (1d4)*3 or 1d(4*3)?

Same question for 1d4^3. Is that (1d4)^3 or 1d(4^3)?

And finally, 'd' itself is non-commutative, so order matters if you chain them! Is 1d4d4 equivalent to (1d4)d4 or 1d(4d4)?
 

log in or register to remove this ad

Sadly, everyone's Dear Aunt Sally doesn't have much say as to the order of precedence of the 'd' in dice notation.

In the case of addition and subtract, it's obvious... 1d4+3 means (1d4)+3.

However, what about 1d4*3? Should that mean (1d4)*3 or 1d(4*3)?

Same question for 1d4^3. Is that (1d4)^3 or 1d(4^3)?

And finally, 'd' itself is non-commutative, so order matters if you chain them! Is 1d4d4 equivalent to (1d4)d4 or 1d(4d4)?

'd' is definitely non-commutative because xdy is not equal to ydx unless x = y. :)
 

Also, I think 1d4d4 would be equivalent to (1d4)d4 merely because 1d(4d4) assumes I have a d16 and I don't even though I could just use 2d8 but then things start getting messy.
 

Here's what I do. Specifically, I don't handle things like 1d3d4, since I've never seen that in use. I also don't handle expressions within a roll, since I haven't seen that one either. So "d" binds to the numbers adjacent to it and has the highest precedence.

Code:
qexpr : '(' expr ')'    { $$ = $2; }
      | plusexpr 
      | minusexpr
      | timesexpr
      | divexpr
      | VAR
      ;

plusexpr : '(' expr '+' expr ')'  { $$ = node_create('+');
                                  node_adopt($$, node_make_sib($2, $4)); }

	 ;

minusexpr : '(' expr '-' expr ')'  { $$ = node_create('-');
                                  node_adopt($$, node_make_sib($2, $4)); }

	  ;

timesexpr : '(' expr '*' expr ')'  { $$ = node_create('*');
                                  node_adopt($$, node_make_sib($2, $4)); }

	  ;

divexpr : '(' expr '/' expr ')'	{ $$ = node_create('/');
				  node_adopt($$, node_make_sib($2, $4)); } 
	;


expr : dicespec		{ $$ = $1; }
     | qexpr		{ $$ = $1; }
     | NUM		{ $$ = $1; }
     ;
dicespec : 'H' NUM '|' rollspec { $$ = node_create(DICEHIGH); 
				  node_adopt($$, node_make_sib($2, $4)); }
	 | 'L' NUM '|' rollspec { $$ = node_create(DICELOW); 
				  node_adopt($$, node_make_sib($2, $4)); }
	 | rollspec		
	 ;

rollspec : NUM 'd' NUM	{ $$ = node_create(DICE); 
			  node_adopt($$, node_make_sib($1, $3)); }
	 | NUM 'o' NUM	{ $$ = node_create(DICEOPEN); 
			  node_adopt($$, node_make_sib($1, $3)); }
	 | NUM 'o' '+' NUM	{ $$ = node_create(DICEOPENHIGH); 
			  node_adopt($$, node_make_sib($1, $3)); }
	 | NUM 'o' '-' NUM	{ $$ = node_create(DICEOPENLOW); 
			  node_adopt($$, node_make_sib($1, $3)); }
	 ;
 

Sadly, everyone's Dear Aunt Sally doesn't have much say as to the order of precedence of the 'd' in dice notation.

In the case of addition and subtract, it's obvious... 1d4+3 means (1d4)+3.

However, what about 1d4*3? Should that mean (1d4)*3 or 1d(4*3)?

Same question for 1d4^3. Is that (1d4)^3 or 1d(4^3)?

And finally, 'd' itself is non-commutative, so order matters if you chain them! Is 1d4d4 equivalent to (1d4)d4 or 1d(4d4)?

"d" on its own has no meaning. Asking where to put the brackets in the above expressions is like asking whether pi*2 is meant to be taken as pi(*2) or p(i*2).
 

"d" on its own has no meaning. Asking where to put the brackets in the above expressions is like asking whether pi*2 is meant to be taken as pi(*2) or p(i*2).

Of course it does! "d" has exactly as much meaning as "+", "-", "*", "/", and "^" (exponentiation).

They're all binary operators. In fact, "d", "-" and "^" are particularly comparable, since the order of the operands matter.

"d" means "generate a random integer between 1 and the quantity on the right-hand side, inclusive, a number of times equal to the quantity on the left-hand side. Then sum the random numbers so generated."
 


Sadly, everyone's Dear Aunt Sally doesn't have much say as to the order of precedence of the 'd' in dice notation.

In the case of addition and subtract, it's obvious... 1d4+3 means (1d4)+3.

However, what about 1d4*3? Should that mean (1d4)*3 or 1d(4*3)?

Same question for 1d4^3. Is that (1d4)^3 or 1d(4^3)?

Why would you want 1d4*3 to mean 1d(4*3)? If you meant that, you would have written 1d12. Obviously 1d4¤3 means (1d4)¤3, no matter what ¤ means so long as ¤ is a function.

And finally, 'd' itself is non-commutative, so order matters if you chain them! Is 1d4d4 equivalent to (1d4)d4 or 1d(4d4)?

You mean non-associative. It seems moot, since no one is using the terminology that way; if you are, you get to define it. And then justify why you're using such a complex dice rolling system. Personally, I'm all for linear 1dx or roughly bell shaped 3d6, or ndx for stuff like damage. Stuff like White Wolf's system is extra complexity that doesn't improve anything; this would be unplayable with physical dice and pointlessly complex on computer.
 

Of course it does! "d" has exactly as much meaning as "+", "-", "*", "/", and "^" (exponentiation).

They're all binary operators. In fact, "d", "-" and "^" are particularly comparable, since the order of the operands matter.

"d" means "generate a random integer between 1 and the quantity on the right-hand side, inclusive, a number of times equal to the quantity on the left-hand side. Then sum the random numbers so generated."

"dn" means "roll a die with a number of sides equal to n and use the result in this equation", where "n" is a set of integer values representing valid die sizes.
 

Rule - d is always followed by "n" where "n" is the set of integer values equal to the available die sizes. This is equated to dn in all formulas.
Standard sizings be as follows: 4/6/8/10/12/20/100
Occassionally other sizings are available as well but are unimportant to our discussion (looking at you 30 and 72).

An equation of 1d(n*3) is invalid as the value of d is incomplete. Because the resulting (n*3) may not equal an acceptable "n" available value.

Also you have to take into an account that d comes first in the order of math. As it denotes a range of values. In the case of 1d4*3 denotes 1 thru 4 times 3. This puts the answer into a range of 3 - 12. But the following numbers would be the only valid answers. 3, 6, 9, 12. Where if you solved the 4*3 first you would have a range of 1-12 with all of the numbers being valid.
Thereby d has to be solved first.
 

Remove ads

Top