def main(): num_trials = 10000 print_histograms = True histogram_bins = 10 consider_to_hit = True weapons = [] w1 = Weapon(dmg=13, acc=0, category='polearms', name='trishula', slay=9, st_bonus=0, brand='none') weapons.append(w1) w2 = Weapon(dmg=12, acc=1, category='polearms', name='demon trident', slay=9, st_bonus=0, brand='electrocution') weapons.append(w2) you = Player(strength=31, dex=10, extra_slay=3, size='medium') you.set_skill('fighting', 23.8) you.set_skill('polearms', 17) you.set_skill('armour', 22) you.set_skill('shields', 25) enemy = Monster(ac=0, ev=0) for weap in weapons: result_list = [] for _ in range(num_trials): hit = True if (consider_to_hit): to_hit = you.get_to_hit(weap) hit = enemy.get_hit(to_hit) if (hit): dmg = final_damage(weap, you, enemy) result_list.append(dmg) else: result_list.append('miss') # result_list consists of ints and 'miss' # get dmg_list by turning all 'miss' into 0 dmg_list = [0 if x == 'miss' else x for x in result_list] dmg1 = statistics.mean(dmg_list) print("\n\n" + weap.name + ": " + str(dmg1) + "\n") #print(result_list) if print_histograms: print_histogram(result_list, histogram_bins)