A (slightly overkilled) python module for rolling dice.
Download 1.0 Beta 1
Example
The following example is a simple little command line application that takes a line at a time and tries to roll it.
dicesh.py:
from die_exp import roll
i = raw_input()
while i.strip():
print roll(i)
i = raw_input()
Known issues and bugs
- Function calls don’t currently work.
- Dice Pool stuff is not supported, and it varies too much per system to implement here. You could probably provide functions for specific dice pool mechanics though once that works.
Todo
- Functions (see above)
-
Fudge die support (eg,
4dF) a Fudge die results in a number between -1 and 1. - Provide nice exceptions
Comments
“Slightly overkilled” he says. Like “rabbit-hunting with atomic weapons” slightly overkilled. âmattw
ooh, I wrote one too (with added compatability for Breo’s dicesh.py):
(number_of_rolls, number_of_sides) = raw_input().split(‘d’)
for i in range(number_of_rolls):
print random.randint(1, number_of_sides)
(yes, I know, it won’t actually work without some int()s in there.) â mattw
Yes, that certainly is a feature complete, drop in replacement. Why didnt i think of that :P â brehaut
An improved version of matt’s code that actually behaves a bit like dicesh.py:
import random
(number_of_rolls, number_of_sides) = raw_input().split(‘d’)
sum(random.randint(1, int(number_of_sides)) for i in range(int(number_of_rolls)))
– brehaut
