def distributions(): conditions.clear() dice1 = 8 dice2 = 6 reroll_equal_to = [] reroll_lowest = 0 roll_min = 0 drop_lowest = 0 details = [ dice1, dice2, reroll_equal_to, reroll_lowest, roll_min, drop_lowest ] d20 = d20Set(1) diceset = Diceset([(dice1, dice2)]) action = Action(d20, 0, diceset, crit_numbers=[], fail_dmg_scale=0.5) stats = Statistics(action) stats.collect_statistics() dummystats.clear() dummystats.append(stats.report_statistics()) return render_template('distributions.html', imagepath='static/img/placeholder.png', stats=dummystats, conditions=conditions, collecting=False)
def calculate(): root = os.path.dirname(__file__) dir = os.path.join(root, 'static/img/temp/') files = os.listdir(dir) for file in files: os.remove(os.path.join(dir, file)) alpha = 0.9**len(conditions) statistics = [] i = 0 for details in conditions: d20 = d20Set(1) diceset = Diceset([(details[0], details[1])], details[2], details[3], details[4], details[5]) action = Action(d20, 0, diceset, crit_numbers=[], fail_dmg_scale=0.0) stats = Statistics(action) stats.collect_statistics() stats.plot_histogram(alpha, str(i)) i += 1 statistics.append(stats.report_statistics()) plotname = 'static/img/temp/' for detail in details: plotname = plotname + str(detail) plotname = plotname + '.png' copyconditions = conditions.copy() conditions.clear() plt.savefig(os.path.join(root, plotname)) plt.clf() return render_template('distributions.html', imagepath=plotname, stats=statistics, conditions=copyconditions, collecting=False)