-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
roll.1.in
173 lines (143 loc) · 5.16 KB
/
roll.1.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
.\" Process this file with
.\" groff -man -Tascii foo.1
.\"
.TH @PACKAGE_NAME@ 1 @PACKAGE_DATE@ @PACKAGE_NAME@ "Roll User Manual"
.SH NAME
@PACKAGE_NAME@ \- rolls a user-defined dice sequence
.SH SYNOPSIS
.BR "@PACKAGE_NAME@ " "[" "-hpsv" "] [" "--version" "] expression"
.SH DESCRIPTION
.B @PACKAGE_NAME@
Rolls a user-defined dice sequence. The dices to roll are defined
using dN where N is the number of sides. Dices can be rolled multiple
times by prepending the number of repetitions (e.g., 3d6) and used in
simple mathematical expressions (e.g., 2d8+4).
.SH OPTIONS
.TP
.B \-\-help, \-h
help
.TP
.B \-\-positive, \-p
allow only positive results
.TP
.B \-\-sum-series, \-s
show the sum of roll series
.TP
.B \-\-test
the result of the dice is always 3 (for testing purposes)
.TP
.B \-\-verbose, \-v
verbose (displays the result for each roll)
.TP
.B \--version
prints the version of the program
.SH EXPRESSIONS
Expressions are in dice notation (also known as dice algebra, common
dice notation or RPG dice notation).
Die rolls are expressed in the form NdX or NDX where N is the number of dices
(1 if omitted) and X the number of dice faces.
roll also accepts W (German) or T (Swedish) to specify a dice (D in English)
If the final number is omitted, it is assumed to be a six.
To this basic notation, an additive modifier can be appended, yielding
expressions of the form, NdX+C. The plus can be replaced by a minus
sign ("-") for subtraction. C is a number to be added subtracted from
the final total.
See: http://en.wikipedia.org/wiki/Dice_notation
.SH Percentile dice (d%)
Often, the variable X in the above notation will be "%". Although a
100-sided die does exist, it is both more common and more uniformly
random to use a combination of two ten-sided dice known as percentile
dice, where one die represents tens and the other units. A roll of
two zeroes means 100.
If you want to roll a single 100-sided die use the "d100" notation.
.SH d10x
d10x is equivalent to d10 x d10 and gives a non-linear distribution.
.SH Fudge dice (dF or df)
The Fudge role-playing game system uses customized "Fudge dice" which
have an equal number of plus, minus and blank sides.
.SH Multipliers
In some games, the above notation is expanded to allow for a
multiplier, as in NdXxC or CxNdX, where "x" or "*" denotes
multiplication (can be replaced by "/" for division) and C is a
natural number.
Results are rounded up.
.SH Reroll filters
It is possible to specify restrictions on dice rolls telling which
values to keep and which values to discard by putting a filter after
the dice. If a value is to be discarded the dice is re-rolled until
the result is valid value. You can specify to keep only values bigger
(>), bigger or equal (>=), smaller (<), smaller or equal (<=) or
different (!=) from a given number. The comparator is specified right
after the the die specification (e.g., 1D6>2).
.SH Selective results
It is possible to keep only the M highest or lowest dices with the following notation:
.PD 0
.TP
NdXhM: roll N dices with X sides and keep the highest M results (M must be less or equal N)
.TP
NdXkM: K for keep is equivalent to H for highest
.TP
NdXlM: roll N dices with X sides and keep the lowest M results (M must be less or equal N)
.PD 0
.TP
Or using the abbreviated notation NdX-L to drop the lowest and NdX-H to drop the highest result.
.SH Series and repetitions
It is possible to concatenate top-level expressions with a comma
("expression, expression") and to repeat the execution of an
expression or a set of expressions by using a counter and curly
brackets ("N{ expression}")
.SH Examples
.PD 0
.TP
3d6 rolls 3 6-sided dices and sums the results
(can be abbreviated with "3d")
.TP
1d8 + 3 rolls 1 8-sided die and adds 3
(can be abbreviated by "d8+3")
.TP
d% rolls 2 10-sided dices: one represents the tens and
the other units
.TP
1d6x5 rolls 1 6-sided dice and multiplies the result by 5
.TP
1d6 / 2 rolls 1 6-sided dice and divides the result by 2 (1d3)
.TP
4d6h3 rolls 4 6-sided dices and keeps the 3 highest results
(discarding the lowest)
.TP
4d6-L rolls 4 6-sided dices and discards the lowest
.TP
"6{3d6}" rolls 3d6 6 times (expression
is quoted to avoid the > being interpreted as
redirection by the shell)
.TP
"1d6>2" rolls 1d6 until the result is bigger than 2 (expression
is quoted to avoid the > being interpreted as
redirection by the shell)
.TP
4DF rolls 4 Fudge dices
.TP
.PD 1
.SH Grammar (EBNF)
.PD 0
.TP
expression := term { "+" term | "-" term } .
.TP
term := number | factor [ ("*"|"/") number |
number ("*"|"/") factor | "(" expression ")" .
.TP
factor := number FilteredDice [ ("h"|"H"|"l"|"L"|"k"|"K") number ] | number FilteredDice "-" [ ("h"|"H"|"l"|"L") | FilteredDice .
.TP
FilteredDice := dice | dice (">"|">="|"<"|"<="|"!=") number .
.TP
dice := "d" | "D" | "w" | "W" | "t" | "T" [ number | "%" | "F" | "f" | "x" | "X" ] .
.PD 1
.SH "SEE ALSO"
.BR random (3)
.SH "EXIT STATUS"
@PACKAGE_NAME@ returns a zero exist status if it finds no error in the
supplied expression
.SH BUGS
Please report bugs to: Matteo Corti (matteo (at) corti.li )
.SH AUTHOR
Matteo Corti ( matteo (at) corti.li )