Esempio n. 1
0
def plot_pmf(ax, dist, offset=0, yscale=1.0, **kwargs):
    ax.plot(dist.faces() + offset, 100.0 * yscale * dist.data, **kwargs)


def plot_ehp(ax, dist, offset=0, yscale=1.0, **kwargs):
    ehp = 1.0 / dist.normalize().ccdf()
    ax.plot(dist.faces() + offset, yscale * ehp, **kwargs)


def semilogy_ehp(ax, dist, offset=0, yscale=1.0, **kwargs):
    ehp = 1.0 / dist.normalize().ccdf()
    ax.semilogy(dist.faces() + offset, yscale * ehp, **kwargs)


explode_d10 = pmf.xdy(1, 10).normalize().explode(3)
explode_min_d12_10 = pmf.PMF.from_faces(
    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10]).normalize().explode(3)
explode_min_d20_19_is_20 = pmf.PMF.from_faces(list(range(1, 19)) +
                                              [20, 20]).normalize().explode(3)
explode_min_d20_16plus_is_20 = pmf.PMF.from_faces(
    list(range(1, 16)) + [20] * 5).normalize().explode(3)

figsize = (8, 4.5)
dpi = 120

# d100

fig = plt.figure(figsize=figsize)
ax = plt.subplot(111)
Esempio n. 2
0
figsize = (8, 4.5)
dpi = 120

# d100

fig = plt.figure(figsize=figsize)
ax = plt.subplot(111)

ax.set_xlabel('Number needed to hit')
ax.set_ylabel('EHP multiplier')
ax.grid()

legend = []

semilogy_ehp(ax, pmf.xdy(1, 100))
legend.append('d100')

semilogy_ehp(ax, pmf.xdy(1, 100).advantage())
legend.append('d100 advantage')

semilogy_ehp(ax, pmf.xdy(1, 100).disadvantage())
legend.append('d100 disadvantage')

left = 0
right = 100
top = 100

ax.set_xlim(left = left, right = right)
ax.set_xticks(numpy.arange(left, right+1, 10))
ax.set_ylim(bottom = 0.5, top = top)
Esempio n. 3
0
import pmf
import numpy
import matplotlib as mpl
import matplotlib.pyplot as plt

def calc_ehp(dist):
    return 1.0 / dist.normalize().ccdf()

three_d6 = pmf.xdy(3, 6)

d8 = pmf.xdy(1, 8) + 6
d20 = pmf.xdy(1, 20)
five_d12 = pmf.xdy(5, 12) - 22
explode_d8 = pmf.xdy(1, 8).normalize().explode(3) + 6
explode_d10 = pmf.xdy(1, 10).normalize().explode(3) + 5
explode_d20 = pmf.xdy(1, 20).normalize().explode(3)
geo12 = pmf.PMF([1/12, 11/12], 0).normalize().explode(30) + 3

hl3_d20 = pmf.PMF.from_faces([0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 7, 8, 9, 10, 10]).normalize().explode(3) + 8
hl3 = pmf.geometric(3) + 8

three_d10 = pmf.xdy(3, 10)-12
hl5_d20 = pmf.PMF.from_faces([0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10]).normalize().explode(3)
hl5 = pmf.geometric(5)

hl_d8 = pmf.PMF.from_faces([0, 0, 0, 0, 1, 1, 2, 3]).normalize().explode(3)
hl5_2dice = hl_d8 * 5 + pmf.xdy(1, 5) - 1
hl5_d8_d12 = hl_d8 * 5 + pmf.PMF.from_faces([1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5]) - 1

hl8_2dice = hl_d8 * 8 + pmf.xdy(1, 8) + 2
hl8 = pmf.geometric(8) + 3
Esempio n. 4
0
import pmf
import numpy
import matplotlib as mpl
import matplotlib.pyplot as plt


def plot_ehp(ax, dist, offset=0, **kwargs):
    ehp = 1.0 / dist.normalize().ccdf()
    ax.semilogy(dist.faces() + offset, ehp, **kwargs)


explode_d10 = pmf.xdy(1, 10).normalize().explode(3)
explode_min_d12_10 = pmf.PMF.from_faces(
    [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10]).normalize().explode(3)
explode_min_d20_19_is_20 = pmf.PMF.from_faces(list(range(1, 19)) +
                                              [20, 20]).normalize().explode(3)
explode_min_d20_16plus_is_20 = pmf.PMF.from_faces(
    list(range(1, 16)) + [20] * 5).normalize().explode(3)

figsize = (8, 4.5)
dpi = 120

# half-life 3

fig = plt.figure(figsize=figsize)
ax = plt.subplot(111)

ax.set_xlabel('Number needed to hit')
ax.set_ylabel('EHP multiplier')
ax.grid(which="both")
Esempio n. 5
0
import pmf
import numpy
import matplotlib as mpl
import matplotlib.pyplot as plt


def calc_ehp(dist):
    return 50.0 / dist.normalize().ccdf()


half_life_3 = pmf.geometric(1000, half_life=3).normalize()

half_life_3_sum2 = (half_life_3 + half_life_3).normalize()

explode_d10 = (pmf.xdy(1, 10).explode(3) - 1).normalize()
laplace_3 = (half_life_3 - half_life_3).normalize()
laplace_3_d10 = (pmf.xdy(1, 10).explode(3) -
                 pmf.xdy(1, 10).explode(3)).normalize()
laplace_3_opposed = (laplace_3 - laplace_3).normalize()

half_life_5 = pmf.geometric(1000, half_life=5).normalize()
laplace_5 = (half_life_5 - half_life_5).normalize()

big8 = pmf.PMF.from_faces([0, 0, 0, 0, 1, 1, 2, 3]).normalize().explode(3)
big8_geo3 = (big8 * 3 + pmf.xdy(1, 3) - 1).normalize()
big8_laplace3 = big8_geo3 - big8_geo3

big8_geo5 = (big8 * 5 + pmf.xdy(1, 5) - 1).normalize()
big8_laplace5 = big8_geo5 - big8_geo5
big8_laplace5s_faces = numpy.concatenate(
    (-numpy.flip(big8_geo5.faces()) - 0.5, big8_geo5.faces() + 0.5))
Esempio n. 6
0
import pmf
import numpy
import matplotlib as mpl
import matplotlib.pyplot as plt

x = [4, 5, 6, 8, 10, 12, 16, 20, 24]
factor = 2

y_low = []
y_high = []

y_low_explode = []
y_high_explode = []

for die_size in x:
    die = pmf.xdy(1, die_size).normalize()
    double_die = pmf.xdy(1, int(die_size * factor)).normalize()
    y_low.append(die > double_die)
    y_high.append(die >= double_die)

    die_explode = die.explode(3)
    double_die_explode = double_die.explode(3)
    y_low_explode.append(die_explode > double_die_explode)
    y_high_explode.append(die_explode >= double_die_explode)

print(y_low)
print(y_high)
print(y_low_explode)
print(y_high_explode)

figsize = (8, 4.5)