Skip to content

dyce.d package reference

Lots of common dice and combinations: d1 through d20, d24, d30, d60, d100, and d00 as well as two and three of d1 through d20 as both H and P objects. For example, a twenty-sided die in H form is d20. In P form, it is pd20. 2 @ d10 in H form is either d10_2 or h2d10. In P form, it is either pd10_2 or p2d10. d0 is the “empty” die (H({})).

For example, consider these different shorthands for expressing 3d6:

 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
>>> from dyce.d import d6, d6_3, h3d6, pd6, pd6_3, p3d6
>>> (3 @ d6) == d6_3 == h3d6 == (3 @ pd6) == pd6_3 == p3d6
True
>>> d6_3 is h3d6  # these are aliases for the same H object
True
>>> pd6_3 is p3d6  # these are aliases for the same P object
True
>>> 3 @ d6 == h3d6, 3 @ d6 is h3d6  # equivalent, but not the same object
(True, False)
>>> p3d6.h() == h3d6, p3d6.h() is h3d6  # equivalent, but not the same object
(True, False)
>>> print(h3d6.format(width=65, scaled=True))
avg |   10.50
std |    2.96
var |    8.75
  3 |   0.46% |#
  4 |   1.39% |#####
  5 |   2.78% |###########
  6 |   4.63% |##################
  7 |   6.94% |###########################
  8 |   9.72% |######################################
  9 |  11.57% |##############################################
 10 |  12.50% |##################################################
 11 |  12.50% |##################################################
 12 |  11.57% |##############################################
 13 |   9.72% |######################################
 14 |   6.94% |###########################
 15 |   4.63% |##################
 16 |   2.78% |###########
 17 |   1.39% |#####
 18 |   0.46% |#