Git Product home page Git Product logo

roll's Introduction

roll

roll is a program to roll dices specified in a simple and intuitive way.

     

see INSTALL on how to compile and install roll and the man page for instructions

Synopsis

roll [-hpsv] [--version] expression

Description

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).

Options

--help, -h
       help

--positive, -p
       allow only positive results

--sum-series, -s
       show the sum of roll series

--verbose, -v
       verbose (displays the result for each roll)

--version
       prints the version of the program

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

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.

d10x

d10x is equivalent to d10 x d10 and gives a non-linear distribution.

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.

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.

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).

Selective results

It is possible to keep only the M highest or lowest dices with the following notation:

  • NdXhM: roll N dices with X sides and keep the highest M results (M must be less or equal N)
  • NdXkM: K for keep is equivalent to H for highest
  • NdXlM: roll N dices with X sides and keep the lowest M results (M must be less or equal N)

Or using the abbreviated notation NdX-L to drop the lowest and NdX-H to drop the highest result.

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}")

Examples

3d6        rolls 3 6-sided dices and sums the results
           (can be abbreviated with "3d")
1d8 + 3    rolls 1 8-sided die and adds 3
                  (can be abbreviated by "d8+3")
d%         rolls 2 10-sided dices: one represents the tens and
           the other units
1d6x5      rolls 1 6-sided dice and multiplies the result by 5
1d6 / 2    rolls 1 6-sided dice and divides the result by 2 (1d3)
4d6h3      rolls 4 6-sided dices and keeps the 3 highest results
           (discarding the lowest)
4d6LX      rolls 4 6-sided dices and discards the lowest
"6{3d6}"   rolls 3d6 6 times (expression
           is quoted to avoid the { and { being interpreted
           by the shell)
"1d6>2"    rolls 1d6 until the result is bigger than 2 (expression
           is quoted to avoid the > being interpreted as
           redirection by the shell)
4DF        rolls 4 Fudge dices

Grammar (EBNF)

expression   := term { "+" term | "-" term } .
term         := number | factor [ ("*"|"x"|"/") number |
                number ("*"|"/") factor | "(" expression ")" .
factor       := number FilteredDice [ ("h"|"H"|"l"|"L"|"k"|"K") number ] | number FiltreredDice ("h"|"H"|"l"|"L") ("X") | FilteredDice .
FilteredDice := dice | dice (">"|">="|"<"|"<="|"!=") number .
dice         := "d" | "D" | "w" | "W" | "t" | "T" [ number | "%" | "F" | "f" | "X" ]

roll's People

Contributors

bastiendurel avatar matteocorti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

roll's Issues

Open-ended variations

Several games use mechanics that allow one or more dice to be rerolled (often a die that rolls the highest possible number), with each successive roll being added to the total. Terms for this include open-ended rolling, exploding dice, and penetration rolls. Games that use such a system include Feng Shui, and Savage Worlds. On Anydice the function to make dice explode on their highest value is called quite simply explode. Another common notation shorthand for exploding dice is to use an exclamation point: AdX! or 6d6!.[3]

Add the "keep" notation

Some games extend the standard notation to AdX(kY)+B where, in addition to the above, Y is the number of dice kept (k) from the roll. Whether the dice omitted are the highest, lowest, or the player's choice depends on the game in question. 7th Sea and Legend of the Five Rings use only 10-sided dice, with notation of the form 8k6, meaning "Roll eight ten-sided dice, keep the highest six, and sum them." Although using a Roll and keep system, Cortex Plus games all use roll all the dice of different sizes and keep two (normally the two best) although a Plot Point may be spent to keep an additional dice, and some abilities let you keep a third automatically.

Allow stacking filter and keep operations

A common house rule for D&D stats is 4d6r1k3 (4d6 reroll 1s keep 3 highest).

I would expect this to be notated as 4d6>1k3. However, these options do not stack, so I'm left rolling 4{d6>1} to see separate rolls, and adding them myself.

Allowing the grammar to fire off multiple filter and keep operations (as well as arithmetic operations) would allow this, as well as rolls where both some number of highest and lowest dice need to be rerolled or kept, e.g.:

8d6-H-H-L-L (roll 8d6 dropping the 2 highest and two lowest)
3d6>1<6 (roll 3d6 rerolling 1s and 6s)

block die

Blood Bowl, also a Games Workshop product, introduces the block die with special notation Xdb or roll block dice X times, blocker/defender chooses (if more than 1 die) with X being one of 3, 2, 1 (usually omitted), -2, -3. Alternatively words for & against can be used to describe a Xdb (in this case X > 0). As an example 2db against is equal to -2db which are both short ways of saying 2 dice block, defender chooses from the results rolled.

d666

In Nomine, a game about Angels and Demons from Steve Jackson Games, uses a three-dice variation called the d666. However, this is actually a combination of 2d6 (for determining success / failure) and 1d6 (for determining degree of success / failure). The notation of d666 is a reference to The Number of the Beast.

Syntax error on NdX-C expressions

The latest version (2.4.0) on Arch Linux throws a syntax error when using expressions of the form NdX-C, e.g., 2d6-3, regardless of spaces around the minus sign.

Issues installing 2.1.0 on Windows 8.1

So I've been trying to install this on Windows 8.1, and (somewhat predictably) I can't get the scripts to execute successfully.

Running sh ./configure on the console gives me:

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.exe
checking for suffix of executables... .exe
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for flex... no
checking for lex... no
checking for bison... no
checking for byacc... no
checking for library containing strerror... none required
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking stdio.h usability... yes
checking stdio.h presence... yes
checking for stdio.h... yes
checking getopt.h usability... yes
checking getopt.h presence... yes
checking for getopt.h... yes
checking errno.h usability... yes
checking errno.h presence... yes
checking for errno.h... yes
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
checking for sys/types.h... (cached) yes
checking for unistd.h... (cached) yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking for atol... yes
checking for srandomdev... no
checking for getpid... yes
checking for qsort... yes
checking for ceil in -lm... yes
checking whether to enable debugging... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating roll.1
config.status: creating VERSION
config.status: creating roll.spec
config.status: creating config.h
config.status: executing depfiles commands

It also spits out:

/c/apps/roll-2.1.0/missing: Unknown `--is-lightweight' option
Try `/c/apps/roll-2.1.0/missing --help' for more information
configure: WARNING: 'missing' script is too old or missing

Attempting to run make after the configure step yields the following error:

make  all-am
make[1]: Entering directory `C:/apps/roll-2.1.0'
gcc -DHAVE_CONFIG_H -I.    -Wall  -g -O2 -MT roll-roll.o -MD -MP -MF .deps/roll-roll.Tpo -c -o roll-roll.o `test -f 'roll.c' || echo './'`roll.c
roll.c: In function 'roll':
roll.c:138:3: warning: implicit declaration of function 'random' [-Wimplicit-function-declaration]
   int res = 1+(int)(((double)dice)*random()/(RAND_MAX+1.0));
   ^
roll.c: In function 'main':
roll.c:249:5: warning: implicit declaration of function 'yy_scan_string' [-Wimplicit-function-declaration]
     yy_scan_string(expression);
     ^
roll.c:251:5: warning: implicit declaration of function 'yyparse' [-Wimplicit-function-declaration]
     yyparse();
     ^
mv -f .deps/roll-roll.Tpo .deps/roll-roll.Po
gcc -DHAVE_CONFIG_H -I.    -Wall  -g -O2 -MT roll-parser.o -MD -MP -MF .deps/roll-parser.Tpo -c -o roll-parser.o `test -f 'parser.c' || echo './'`parser.c
mv -f .deps/roll-parser.Tpo .deps/roll-parser.Po
gcc -DHAVE_CONFIG_H -I.    -Wall  -g -O2 -MT roll-scanner.o -MD -MP -MF .deps/roll-scanner.Tpo -c -o roll-scanner.o `test -f 'scanner.c' || echo './'`scanner.c
scanner.c:1290:17: warning: 'yyunput' defined but not used [-Wunused-function]
     static void yyunput (int c, char * yy_bp )
                 ^
scanner.c:1337:16: warning: 'input' defined but not used [-Wunused-function]
     static int input  (void)
                ^
mv -f .deps/roll-scanner.Tpo .deps/roll-scanner.Po
gcc -Wall  -g -O2   -o roll.exe roll-roll.o roll-parser.o roll-scanner.o  -lm
roll-roll.o: In function `roll':
C:\apps\roll-2.1.0/roll.c:138: undefined reference to `random'
C:\apps\roll-2.1.0/roll.c:138: undefined reference to `random'
C:\apps\roll-2.1.0/roll.c:138: undefined reference to `random'
C:\apps\roll-2.1.0/roll.c:138: undefined reference to `random'
C:\apps\roll-2.1.0/roll.c:138: undefined reference to `random'
collect2.exe: error: ld returned 1 exit status
make[1]: *** [roll.exe] Error 1
make[1]: Leaving directory `C:/apps/roll-2.1.0'
make: *** [all] Error 2

Since the error during make was definitely a failure, I didn't bother with make install.

Any ideas how I can go about fixing this? Am I missing some libraries?

10-sided variations

The Cyborg Commando role-playing game by Gary Gygax uses a dice mechanic called d10x. This is equivalent to d10×d10 and gives a non-linear distribution, with most results concentrated at the lower end of the range. The mean result of d10x is 30.25 and its standard deviation is about 23.82.

6-sided variations

Various Games Workshop systems such as Necromunda and Mordheim use an anomalously named D66 roll, meaning d6×10+d6. There are 36 possible results ranging from 11 to 66. The D66 is a base six variant of the base ten Percentile die (d100). The D66 is generally a combination of two six-sided dice, often made distinguishable from each other by color, or simply one die rolled twice. The first die represents the tens digit, and the second die the ones digit. For example, a roll of 1 followed by a roll of 5 will give a total of 15, while a roll of 3 followed by a roll of 6 will give a total of 36. The mean result of the D66 is 38.5, and the standard deviation about 17.16.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.