RollPlay Dice Strings

RollPlay supports dice strings with the following syntax for specifying collections of dice. The string is made up of one or more of dice descriptions separated by plus or minus signs, like so (square brackets indicate optional forms):

<dice object> = <dice description> [ +|- <dice description> ]*

A dice description describes at most one type of die to be rolled, the number of times to roll it, and a number by which to multiply the description. The dice description can be as simple as a constant. Also part of the dice description is the type of roll to be made (discussed below).

<dice description> = <constant> | <dice form>
<dice form> = [<multipler>][<number of dice>]<roll type><number of sides>[<keep>]
<multipler> = [<number>]x
<roll type> = d | s | t
<keep> = h|l<number to keep>

There are three types of rolls. The roll types are explained below, assuming that the dice form uses n sided dice.:

d

A stanard closed roll. The total dice rolled are added together.

s

A modified open roll. The total dice rolled are added together.

t

A open roll. The total dice rolled are added together.

The optional <keep> portion of a dice form provides a way to keep only a subset of the dice rolled in that dice form. The number following the code letter in the <keep> indicates how many dice to keep. If no <keep> is present, or the number of dice to keep exceeds the number of dice in the dice form, all dice in the form are used.

h The subset of dice with the highest rolls are kept and added together to determine the total for the form.
l The subset of dice with the lowest rolls are kept and added together to determine the total for the form.

Note that there are no parentheses in this system. The multiplier applies to the whole dice form but not the additions following it. This forces you to distribute if you need to. For example, if you wanted to have a die roll that rolled 5 four sided dice, added 2 and then multiplied the entire result by 3, you might be tempted to use 3x(5d4+2). This would be illegal. Instead, you must distribute it into 3x5d4 + 6. While somewhat inconvienent, the resulting formulae are easier to read, and you lose nothing.

Spaces are optional and are totally ignored in the dice object string.

Examples

2

This always returns 2.

d6

Rolls a six sided die

d6+2

Rolls a six sided die and adds two.

2d6

Rolls two six sided dice and adds them. This is mathematically equivalent to d6 + d6.

2d6-1

Rolls two six sided dice and adds them, then subtracts one.

3x2d6

Rolls two six sided dice and adds them, then multiplies the result by 3. This is mathematically equivalent to 3 * (d6 + d6), not d6 + d6 + d6 + d6 + d6 + d6.

3x2d6+1

Rolls two six sided dice and adds them, then multiplies the result by 3. To this, one is added.

2t8

Rolls two eight-sided open-endedly and adds them.

2t8+1

Rolls two eight-sided open-endedly and adds them, then adds 1.

3x2t8

Rolls two eight-sided open-endedly and adds them, then multiplies each result by three.

6d10h3

Rolls six ten-sided die and adds the three with the highest values together.

7x4d10l2

Rolls four ten-sided die open-endedly. The two with the lowest value are added together and the result is multiplied by seven.

2d4+d70

Rolls two four-sided die and adds them. Then adds a seventy-sided die.

2d4+2t10

Rolls two four-sided die and adds them. Then rolls two ten-sided open-endedly and adds them. Then adds the two sets.

d6-d6

Rolls a six-sided and subtracts another six-sided. This is not equivilant to zero.

Odd Examples

1d6

This is identical to "d6"

xd8

This is identical to "d8"

1xd8

This is identical to "d8"

4d6h1

Roll four six-sided dice and use the value of the largest one.

6d20l2

Roll six twenty-sided dice and use sum the two smallest values.