ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Dice analyzer machine project

<< < (18/19) > >>

mouser:
I was inspired to experiment a little today with the stats and graphs to verify some expectations using simulated data.

So I added some code to let me use the standard python random number generator (which turns out to be quite fair looking) to simulate dice rolls, and then injected some biases to see if they could be detected.

So here is a simulated 20 sided die that is ever so slightly unfair.  It has a 0.2% chance (0.002 probability) that any given roll will be same as previous roll, and a 0.2% chance above normal equal probability that it will land on face side 01.

So our first screenshot is with 10,000 rolls.  The stats analysis of the software says it could very well be a fair die -- insufficient evidence to suggest otherwise:
Dice analyzer machine project

Now we try 100,000 rolls.  And now we start to see a pattern, and we have enough rolls to be pretty certain of our evidence that the die is unfair.  The lower heatmap shows correlations between pairs of rolls -- after 100,000 rolls of a d20 it's hard to visually see patterns there (yet).
Dice analyzer machine project

Let's try a 1,000,000 rolls and see how it looks.  Yep now we are virtually certain that the die is quite biased.  And now in the lower heatmap you can see the hotter colors on the bottom row and leftmost column and on the diagonal, showing the bias between pairs of rolls:
Dice analyzer machine project

And just for the hell of it here are 10,000,000 rolls:
Dice analyzer machine project

mouser:
I really want to return to this project and do a second version of it.. I'm still convinced that some better hardware (maybe 3d printed) that implemented a clever way of centering the die roll landing position would make all the difference,
--- End quote ---

I'm thinking now that perhaps a small robot arm would be the coolest solution -- and have the advantage of being able to potential evaluate "realistic" dice "rolling" (randomization) mechanisms.

---ICEMAN---:
Id love to help out with this project, (Ive got a 3d printer and have a background in robotics) but trying to learn a bit about machine learning and openCV. Any chance this code is public so I can help contribute to the software and hardware?

mouser:
I did open source the code, though it's a bit rough.
I should upload my very recent changes.

https://github.com/dcmouser/dicer

---ICEMAN---:
Sounds good, ill take a look and start playing around when you update the repo. Looking forward to getting back into printing and side projects and learning a bit more about openCV when things calm down after the holidays. Id like to 3d print an efficient dice testing rig for my D&D sets (several are steel so itll have to be robust) to ensure they are close to fair.