dicey

A dice probability calculator.

Stars
5

Dicey

dicey.js.org

About

Dicey is based on the wonderful AnyDice made by Jasper Flick. The syntax has been changed somewhat, with dice notation being aligned closer to Foundry and Roll20. Dicey runs completely in the browser, and can be used offline when saved to your phone's homescreen.

Dicey is open-source under the MIT license. Development takes place on github.

I think I found a problem with your math.

Please file a bug report on the Issue Tracker.

Can I use Dicey in my app?

Most likely. There is a sub-module inside dicey called dicey-math, however the API to interact with it is still pretty rough. It's on the todo list to clean this up.

Can I define functions like in AnyDice or SnakeEyes

Not yet. The goal of dicey is to take dice expressions directly from various games and compute the odds declaratively. This is something we would like to add eventually.

Documentation

Dicey is based on the wonderful AnyDice made by Jasper Flick. The syntax has been changed somewhat, with dice notation being aligned closer to Foundry and Roll20.

Basics

Dicey fundamentally operates as a calculator, but instead of operating only on numbers, it can also operate on probabilities.

As an overly simple example, let's add two and two together. You can click on the example to load it.

output 2+2

Notice the calculation starts with the word output. This instructs Dicey to display the result. You can leave this out, but it's good to know about if you want to output multiple things.

output 2+2 output 2+2*2

Dice

As a simple example, 3d6 represents rolling three six-sided dice.

The arguments to the die operator aren't limited to numbers. If a d{4,5,10} sets is passed to the right hand argument, the elements of that set will make up the sides of the die. Similarly a probability can be used as the second argument to give chance to roll die with that number of sides. 2d(d6) would be analogous to rolling a d6 to determine which type of dice to pick up, and then rolling two of those types of dice.

Sets

Sets are formed by placing comma separated elements between {}'s. For example {3,4,5} is a set of three numbers. By default, the elements of a set are added together and displayed as one number. This can be disabled with the collapse toggle at the bottom of the calculator page. Sets are by convention stored in descending order.

> {3d6, d10} kh 1 - Take the highest roll between 3d6 and d10.

Operators

The standard math operators + - * / are defined as normal, with standard order of operation.

The comparison operators > >= < <= == != use the values 1 and 0 as their output instead of true and false respectively. These operators can be modified with cs ms ro zu as per Foundry Die Modifiers

The kl lh dl dh binary operators also work as per Foundry.

Functions

Function calls are made similar to C-style languages. For example max(d6) represents calling the max function and passing d6 as its only argument.

See the function reference for a list of built-in functions.