Example #1
0
def iter_explode(die_size):
    for i in range(1, die_size - 1):
        for j in range(i + 1, die_size - 1):
            name = 'success on %d+, explode on %d+' % (i + 1, j + 1)
            explode_chance = (die_size - j) / die_size
            yield Die.from_faces([0] * i + [1] * (die_size - i)).explode(
                10, chance=explode_chance).rename(name)
Example #2
0
def iter_negative_success(die_size):
    for i in range(1, die_size - 1):
        for j in range(i + 1, die_size - 1):
            name = 'success on %d+, negative success on %d or lower' % (j + 1,
                                                                        i)
            yield Die.from_faces([-1] * i + [0] * (j - i) + [1] *
                                 (die_size - i - j)).rename(name)
Example #3
0
def iter_dice(die_size, explode):
    for faces in iter_faces(die_size):
        base_die = Die.from_faces(faces)
        if not explode:
            yield base_die.rename('d' + str(die_size) + str(faces))
        else:
            if faces[0] == -1: return
            max_explode = min(
                faces.count(1) // 2, faces.count(0), die_size // 4)
            for explode_faces in range(1, max_explode + 1):
                if faces[-explode_faces] != 1: break
                explode_chance = explode_faces / die_size
                yield base_die.explode(10, chance=explode_chance).rename(
                    'd%d%s!%s' % (die_size, faces, explode_faces))
Example #4
0
def iter_exploding_dice():
    for die_size in [4, 6, 8, 10, 12]:
        for i in range(1, die_size):
            faces = [0]*i + [1]*(die_size-i)
            for num_explode in range(0, die_size-i+1):
                metadata = {
                    'size' : die_size,
                    'threshold' : i+1,
                    'feature' : 'none',
                    'faces' : [str(x) for x in faces],
                    'notes' : '',
                    }
                if num_explode == 1:
                    metadata['feature'] = 'explode on %d' % die_size
                elif num_explode == (die_size-i):
                    metadata['feature'] = 'explode on any success'
                elif num_explode > 0:
                    metadata['feature'] = 'explode on %d+' % (die_size - num_explode + 1)
                for j in range(num_explode):
                    metadata['faces'][-1-j] += '!'
                if die_size == 10 and i == 7 and num_explode == 1: metadata['notes'] = 'New World of Darkness'
                yield Die.from_faces(faces).explode(200, chance=num_explode/die_size), metadata
Example #5
0
        fig = plt.figure(figsize=figsize)
        ax = plt.subplot(111)

        ax.plot(g_x, g_ccdf * 100.0, linestyle=':')
        ax.plot(x_ccdf, ccdf * 100.0, marker='.')

        ax.grid()
        ax.set_xlim(left, right)
        ax.set_xlabel('Deviation from mean (SDs)')
        ax.set_ylabel('Chance to hit (%)')
        ax.set_ylim(0, 100.0)
        ax.set_title('%d pool size (KS = %0.2f%%)' % (pool_size, ks * 100.0))
        ccdf_frame_path = 'output/frames/ccdf_%03d.png'
        plt.savefig(ccdf_frame_path % frame_index,
                    dpi = dpi, bbox_inches = "tight")
        plt.close()
    make_webm(pmf_frame_path, 'output/success_pool_roe_%s_pmf.webm' % name)
    make_webm(ccdf_frame_path, 'output/success_pool_roe_%s_ccdf.webm' % name)

#make_anim(Die.coin(1/6), 'd6_2plus')
#make_anim(Die.coin(2/6), 'd6_3plus')
make_anim(Die.coin(3/6), 'd6_4plus')
#make_anim(Die.coin(4/6), 'd6_5plus')
#make_anim(Die.coin(5/6), 'd6_6plus')
exalted2e = Die.from_faces([0]*6 + [1]*3 + [2])
owod = Die.from_faces([-1] + [0]*5 + [1]*4)
nwod = Die.from_faces([0]*7 + [1]*3).explode(10, chance=0.1)
#make_anim(exalted2e, 'exalted2e')
#make_anim(owod, 'owod')
#make_anim(nwod, 'nwod')
Example #6
0
fig = plt.figure(figsize=figsize)
ax = plt.subplot(111)

plot_pmf(ax, Die.coin(1 / 6), die_counts_simple, '(d6>=6)')

ax.set_xlim(left=left, right=right)
ax.set_ylim(bottom=0)
plt.savefig('output/sum_pool_6plus.png', dpi=dpi, bbox_inches="tight")

# exalted 2e

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

plot_pmf(ax, Die.from_faces([0] * 6 + [1] * 3 + [2]), die_counts_simple,
         'dExalted2e')

ax.set_xlim(left=left, right=right)
ax.set_ylim(bottom=0)
plt.savefig('output/sum_pool_exalted2e.png', dpi=dpi, bbox_inches="tight")

# owod

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

plot_pmf(ax, Die.from_faces([-1] + [0] * 5 + [1] * 4), die_counts_simple,
         'dOWoD')

ax.set_xlim(left=left, right=right)
Example #7
0
# 5+ on d6

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

plot_opposed_fixed_side(ax, Die.coin(1 / 3), die_counts_simple, '(d6>=5)')

ax.set_xlim(left=left, right=right)
plt.savefig('output/add_pool_opposed_5plus.png', dpi=dpi, bbox_inches="tight")

# exalted 2e

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

plot_opposed_fixed_side(ax, Die.from_faces([0] * 6 + [1] * 3 + [2]),
                        die_counts_simple, 'Exalted2e')

ax.set_xlim(left=left, right=right)
plt.savefig('output/add_pool_opposed_exalted2e.png',
            dpi=dpi,
            bbox_inches="tight")

# coin

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

plot_opposed_fixed_side(ax, Die.d(6), die_counts_simple, '6')

ax.set_xlim(left=left, right=right)
Example #8
0
def iter_simple_dice(die_size):
    # standard die
    metadata = {
        'size' : die_size,
        'threshold' : 0,
        'feature' : 'standard die',
        'faces' : [str(x) for x in range(1, die_size+1)],
        'notes' : '',
    }
    yield Die.d(die_size), metadata
    # exploding standard die (problem: VMR too high to be useful)
    """
    metadata = {
        'size' : die_size,
        'threshold' : 0,
        'feature' : 'exploding standard die',
        'faces' : [str(x) for x in range(1, die_size+1)],
        'notes' : '',
    }
    metadata['faces'][-1] += '!'
    yield Die.d(die_size).explode(10), metadata
    """
    # odd standard dice
    if die_size % 2 == 0 and die_size >= 6 and die_size <= 10:
        metadata = {
            'size' : die_size-1,
            'threshold' : 0,
            'feature' : 'standard die',
            'faces' : [str(x) for x in range(1, die_size-1+1)],
            'notes' : '',
        }
        yield Die.d(die_size-1), metadata
    # no feature
    for i in range(1, die_size):
        faces = [0]*i + [1]*(die_size-i)
        metadata = {
            'size' : die_size,
            'threshold' : i+1,
            'feature' : 'none',
            'faces' : [str(x) for x in faces],
            'notes' : '',
            }
        if die_size == 6 and i == 3: metadata['notes'] = 'Burning Wheel'
        if die_size == 6 and i == 4: metadata['notes'] = 'Shadowrun 4e'
        yield Die.from_faces(faces), metadata
    # negative on 1
    for i in range(2, die_size):
        faces = [-1] + [0]*(i-1) + [1]*(die_size-i)
        metadata = {
            'size' : die_size,
            'threshold' : i+1,
            'feature' : '-1 success on bottom face',
            'faces' : [str(x) for x in faces],
            'notes' : '',
            }
        if die_size == 10 and i == 6: metadata['notes'] = 'Old World of Darkness'
        yield Die.from_faces(faces), metadata
    # double on max
    for i in range(1, die_size-1):
        faces = [0]*i + [1]*(die_size-i-1) + [2]
        metadata = {
            'size' : die_size,
            'threshold' : i+1,
            'feature' : '2 successes on top face',
            'faces' : [str(x) for x in faces],
            'notes' : '',
            }
        if die_size == 10 and i == 6: metadata['notes'] = 'Exalted 2e'
        yield Die.from_faces(faces), metadata
    # explode
    for i in range(1, die_size):
        faces = [0]*i + [1]*(die_size-i)
        metadata = {
            'size' : die_size,
            'threshold' : i+1,
            'feature' : 'explode on top face',
            'faces' : [str(x) for x in faces],
            'notes' : '',
            }
        metadata['faces'][-1] += '!'
        if die_size == 10 and i == 7: metadata['notes'] = 'New World of Darkness'
        yield Die.from_faces(faces).explode(100, chance=1/die_size), metadata
    """
Example #9
0
def iter_double_success(die_size):
    for i in range(1, die_size - 1):
        for j in range(i + 1, die_size - 1):
            name = 'success on %d+, double success on %d+' % (i + 1, j + 1)
            yield Die.from_faces([0] * i + [1] * (j - i) + [2] *
                                 (die_size - i - j)).rename(name)