Inspiration
It is relatively well known that when rolling two dice, some results are more likely than others (when looking at the sum). One of our team members was curious about what the probability curve (or whatever it is called) would look like for multiplication, subtraction, or even what it looks like with advantage or disadvantage.
What it does
Given a formula for dice to roll, it works out every possible result, including every way to get there. IT then displays it as a graph using Bokeh.
How I built it
The formula is first reordered into reverse polish notation, so that operator precedence is not an issue when calculating the results. Then, the formula gets added to a queue. If the next operator on the list is a single die, then each possible result gets added to the queue. If it is many, then they get split into a sum. if it is a normal operator, it gets evaluated. When there are no more operations left to be evaluated, the results are tallied, and this result gets sent to the graphing system.
Challenges I ran into
Mark:
At first, I wanted to develop the dice roll simulator in a faster language, like C or C++. However the official way of doing it seemed to complicated to learn in under 24 hours (since I knew it was going to be quite a challenge to actually implement the algorithm), so I looked for some alternatives.
Boost.python looked promising, but after about half a day of trying to get it to work, I found that for some reason it requires a really strange build system to work properly, and the sample file from the tutorial was missing.
I ended up making the dice roller in python and it shows, performance-wise.
Hasnain:
The program that would parse the equation and produce a probability for each result needed each of the characters to be separated by empty spaces, and it would then split it up into a list. My challenge was to turn the user input into the same, I tried to think about separating them with white spaces but I figured that would be a waste of time instead, I could straight up input the list to the parser.
Secondly when developing the flask application the graph wouldn't show up when added in a different directory other than the one with the python script that was producing it and flask required all HTML files that needed to be rendered in a separate folder called templates, I tried to use the shutil module to move the files around but to no avail was I able to accomplish what I needed although I found a very helpful online video that would embed the graphs using flask instead of creating a new file, which proved to be quite helpful as the graph could now be updated in real-time.
Accomplishments that I'm proud of
Mark:
I'm proud that I have actually implemented all the features that were planned for my part of the project.
Hasnain:
I am really proud of successfully deploying a flask web app and learning so much more about the different algorithms through my teammates. I am also very happy with the progress that I have made and the different skills I have learnt in this hackathon including graphing and embedding webpages using Flask and Bokeh
What I learned
What's next for Breadth first dice roller
At the moment, the program's memory usage goes up exponentially, and it doesn't spread that usage out in a sensible manner. Because it goes breadth-first, it uses most of this in a spike. we could also have a simulator that also simulates the dice as well as add a specific query box where the user can specifically query the die and the number as well as it's probability.
Log in or sign up for Devpost to join the conversation.