from die import Die

import pygal

# create a D6 and a D10
die_1 = Die(8)
die_2 = Die(8)

# roll the dice many times and keep the results in a list
results = []
for roo_num in range(500000):
    result = die_1.roll() + die_2.roll()
    results.append(result)

# analyze the results
frequencies = []
max_result = die_1.num_sides + die_2.num_sides
for value in range(2, max_result+1):
    frequency = results.count(value)
    frequencies.append(frequency)

# visualize
hist = pygal.Bar()

hist.title = "Results of rolling two D8 50,000 times"
hist.x_labels = []
for i in range(2, max_result+1):
    hist.x_labels.append(str(i))
hist.x_title = "Result"
hist.y_title = "Frequency of Result"

hist.add('D8 + D8', frequencies)
hist.render_to_file('D8_dice_visual.svg')
