https://github.com/stocks29/dice
Roll the dice, in elixir
https://github.com/stocks29/dice
Last synced: 8 months ago
JSON representation
Roll the dice, in elixir
- Host: GitHub
- URL: https://github.com/stocks29/dice
- Owner: stocks29
- Created: 2015-02-08T21:19:55.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2016-12-13T17:46:59.000Z (over 9 years ago)
- Last Synced: 2025-07-07T13:40:50.189Z (9 months ago)
- Language: Elixir
- Size: 4.88 KB
- Stars: 14
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - Roll the dice, in Elixir. (Examples and funny stuff)
- fucking-awesome-elixir - dice - Roll the dice, in Elixir. (Examples and funny stuff)
- awesome-elixir - dice - Roll the dice, in Elixir. (Examples and funny stuff)
- fucking-awesome-elixir - dice - Roll the dice, in Elixir. (Examples and funny stuff)
README
Dice
====
Test the results of rolling different sided dice.
### Add as Dependency
```elixir
{:dice, "~> 0.0.1"}
```
### Build CLI App
```bash
mix escript.build
```
### Run CLI App
```bash
./dice $num_trials $num_sides_die_1 $num_sides_die_2 $num_sides_die_3 ...
```
### Use Library
```elixir
# Create 2 x 6-sided die
dice = Dice.new([6, 6])
# Roll the dice
result = Dice.roll(dice)
# => 7
# Run several trials of the dice
results = Dice.trials(dice, 1000)
# => %{2 => 19, 3 => 52, 4 => 53, 5 => 81, 6 => 89, 7 => 167, 8 => 158, 9 => 118, 10 => 118, 11 => 86, 12 => 59}
```