Release 1

Part Two - "Dice"

Section One - "Definitions"

[ The dice mechanics are stolen from The Reliques of Tolti-Aph ]

[ The dice code is further based on Benjamin Penney's "To Hit", posted to rec.arts.int-fiction on 19 June 2010]

A die roll is a kind of value. 9d100+29 specifies a die roll with parts dice, sides (without leading zeros), modifier (without leading zeros, optional, preamble optional).

A singular die roll is a kind of value. d100+29 specifies a singular die roll with parts sides (without leading zeros), modifier (without leading zeros, optional, preamble optional).

A subtractive die roll is a kind of value. 9d100-29 specifies a subtractive die roll with parts dice, sides (without leading zeros), modifier (without leading zeros, optional, preamble optional).

A singular subtractive die roll is a kind of value. d100-29 specifies a singular subtractive die roll with parts sides (without leading zeros), modifier (without leading zeros, optional, preamble optional).

Understand "roll [singular die roll]" as test_rolling singular. Understand "dice [singular die roll]" as test_rolling singular. Understand "shoot [singular die roll]" as test_rolling singular. Understand "throw [singular die roll]" as test_rolling singular. test_rolling singular is an action applying to one singular die roll.

Instead of an actor test_rolling singular:

let the roll be the singular die roll understood;

try the actor test_rolling the die roll with dice part 1 sides part (the sides part of the roll) modifier part (the modifier part of the roll) instead.

Understand "roll [subtractive die roll]" as test_rolling subtractive. Understand "dice [subtractive die roll]" as test_rolling subtractive. Understand "shoot [subtractive die roll]" as test_rolling subtractive. Understand "throw [subtractive die roll]" as test_rolling subtractive. test_rolling subtractive is an action applying to one subtractive die roll.

Instead of an actor test_rolling subtractive:

let the roll be the subtractive die roll understood;

try the actor test_rolling the die roll with dice part (0 minus the dice part of the roll) sides part (0 minus the sides part of the roll) modifier part (0 minus the modifier part of the roll) instead.

Understand "roll [singular subtractive die roll]" as test_rolling singular subtractive. Understand "dice [singular subtractive die roll]" as test_rolling singular subtractive. Understand "shoot [singular subtractive die roll]" as test_rolling singular subtractive. Understand "throw [singular subtractive die roll]" as test_rolling singular subtractive. test_rolling singular subtractive is an action applying to one singular subtractive die roll.

Instead of an actor test_rolling singular subtractive:

let the roll be the singular subtractive die roll understood;

try the actor test_rolling the die roll with dice part -1 sides part (0 minus the sides part of the roll) modifier part (0 minus the modifier part of the roll) instead.

test_rolling is an action out of world applying to one die roll.

Understand "roll [die roll]" as test_rolling. Understand "dice [die roll]" as test_rolling. Understand "shoot [die roll]" as test_rolling. Understand "throw [die roll]" as test_rolling.

test_rolling craps is an action out of world applying to nothing.

Understand "roll" as test_rolling craps when the polyhedra are visible. Understand "dice" as test_rolling craps. Understand "shoot" as test_rolling craps when the polyhedra are visible.

The craps-point is a number that varies. The craps-point is 0.

To decide what number is the modulus of (n - a number):

if n is less than 0

begin;

decide on 0 minus n;

otherwise;

decide on n;

end if.

To say (d - a number) die/dice with (ss - a number) sides adding (m - a number):

say "[if d is not 1][d][end if]d[ss][if m is greater than 0]+[m][otherwise if m is less than 0][m][end if]".

To decide what number is the roll of (d - a number) die/dice with (ss - a number) sides adding (m - a number):

let the total be m;

say "[if d is not 1][d][end if]d[ss][if m is greater than 0]+[m][otherwise if m is less than 0][m][end if]: ";

repeat with counter running from 1 to d

begin;

let the roll be a random number from 1 to ss;

if the counter is not 1, say " + ";

say the roll;

increase the total by the roll;

end repeat;

if m is 0 and d is 1, decide on the total;

if m is not 0, say "[if m is greater than 0] + [m][otherwise] - [modulus of m][end if] ";

decide on the total.

Notes

[1]. RPGs are games of chance as well as skill, and the actual rolling of the dice is as much a part of the experience as the randomised outcome. The polyhedral four-, six-, eight-, ten-, twenty- and even hundred-sided dice ubiquitous to RPGs are pleasingly exotic in the hand, but also make possible a wide range of random distributions. W&W uses the traditional notation for such rolls (which evolved as the D&D rules went through successive printings, but became standard around 1980): "3d6+2" means we should roll three six-sided dice, add up the scores showing, then add 2.

[2]. The optional nature of the adds part of a die roll means that "2d4", for instance, is also a legal form. Again, this is a convention imitating the tables which appear in printed RPG rulebooks. What Inform means by the preamble to the adds part is the plus sign: if this had not been specified to be optional, "2d4+" would be legal.

[3]. We added the pointless verb "roll" as a harmless convenience for testing that die rolls work: if the player types "ROLL 3D6+2", the game might reply "For your own amusement, you roll 3d6+2: 2,5,4+2=13, making thirteen."