topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 5:22 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: Dice analyzer machine project  (Read 54564 times)

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #75 on: February 25, 2016, 01:45 AM »
As educational as this project was, it seems to me that my intention of building a standalone Raspberry Pi powered ART PROJECT may not come to fruition, just because of the sheer amount of additional work it would take to make a nice user-friendly GUI interface and how hard it would be to make the code truly reliable enough that you could drop in any die and have it analyzed, and due to the slow speed of the RPI version of the code.

So it may be that I need to find another RPI art project idea..

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #76 on: February 25, 2016, 03:46 AM »
5000+ Rolls of a D20:

Screenshot - 2_25_2016 , 3_45_37 AM.png

Looks like these discount bags-o-dice i bought leave something to be desired in terms of fairness!
« Last Edit: February 25, 2016, 04:02 AM by mouser »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #77 on: February 25, 2016, 03:58 AM »
ps. not enough data to make this useful but if you like pretty charts, here's the heatmap showing the die face transitions for those 5000 rolls:
Screenshot - 2_25_2016 , 3_57_40 AM.png

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #78 on: February 25, 2016, 09:42 AM »
I wanted to check if the initial biased results above indicating that some die faces are significantly less likely to be rolled, still hold up if the experiment is repeated -- or were just random spikes in the data.
As a nice demonstration of the power of statistics, here's a completely INDEPENDENT run of another 5900 rolls of this same die:

Screenshot - 2_25_2016 , 9_38_40 AM.png

Notice the same basic pattern as the first chart in terms of which die faces are more and less likely to come up.  Pretty darn cool.  :up: :up: :up:
« Last Edit: February 25, 2016, 09:58 AM by mouser »

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 11,186
    • View Profile
    • Donate to Member

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Points: 1
  • Posts: 9,747
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #80 on: February 25, 2016, 03:28 PM »
Are the numbers in those statistics ordered? e.g., If it rolls a 19, is that a 19 on the chart? Or is it more like "recognized pattern number 19" (referred to as classes in this post)?

And finally, how do you eliminate the possibility that it's your rolling mechanism which is unfair?

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #81 on: February 25, 2016, 03:40 PM »
If it rolls a 19, is that a 19 on the chart?
yes, after the system creates its clusters automatically, i rename the clusters according to their die faces.

And finally, how do you eliminate the possibility that it's your rolling mechanism which is unfair?

This is somewhat of a philosophical question.

The only thing you can really say from these results is that the die rolling outcome results are biased.

However, what we can say is that there doesn't appear to be any clear pattern in terms of transitions in the heat map that would suggest that the die roller is doing weird things like flipping the die between alternate faces.
To help validate that the rolling procedure was as fair as possible you could try comparing results to different rolling mechanisms, or more practically, i could extend the rolling times to see if that made much of a difference.  Finding some high quality trusted fair dice that evaluated to fair using the system would give more confidence.

But to see why this has to be approached somewhat philosophically, just consider how physically the die might be biased -- it could be because of uneven weighting, or assymetric shape, or rounded vs sharp corners, etc.  And these will effect different "rolling" procedures differently.  So the way the bias will show up is dependent on the way in which the dice are "rolled" (randomized).  The best we can say is that when the die is rolled in this fashion, they exhibit this bias.  If you asked a human to roll the dice to test for bias, you would have the same problem -- the bias may show up differently based on whether the user "shakes" the dice in their hand and drops them to the table, or rolls them a far distance against a wall, etc.

If you really wanted to be more specific about bias of dice for human use, you could try to ascertain whether the biases found by one rolling machine matched the biases found by a certain human method of rolling dice.
« Last Edit: February 25, 2016, 08:53 PM by mouser »

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,612
    • View Profile
    • Donate to Member
Re: Dice analyzer machine project
« Reply #82 on: February 25, 2016, 04:04 PM »
the camera on the Raspberry Pi, while high resolution, has absolutely no focus control and would not focus well on anything shorter than about 24 inches from it
This page on eLinux.org list a lot of (usb) cameras that are tested with the RPi, but I don't know if they are compatible with the python libraries you've used. Some of them will have better focus control, and you might even own one of them listed ;)
It's not going to enhance the (lack of) processing-speed of the RPi, though :huh:

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • default avatar
  • Posts: 11,186
    • View Profile
    • Donate to Member
Re: Dice analyzer machine project
« Reply #83 on: February 28, 2016, 09:09 PM »
Thought you might find this interesting:

https://www.kickstar...agined/posts/1504651

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #84 on: December 01, 2017, 12:38 AM »
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, since I believe the major difficulty with the visual recognition is the fact that the die final resting point for different rolls can really skew its appearance and confuse the recognition system.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #85 on: December 01, 2017, 04:03 AM »
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:
Screenshot - 12_1_2017 , 3_51_35 AM.pngDice 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).
Screenshot - 12_1_2017 , 4_00_26 AM.pngDice 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:
Screenshot - 12_1_2017 , 4_02_32 AM.pngDice analyzer machine project

And just for the hell of it here are 10,000,000 rolls:
Screenshot - 12_1_2017 , 4_04_56 AM.pngDice analyzer machine project
« Last Edit: December 02, 2017, 11:17 PM by mouser »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #86 on: December 01, 2017, 02:18 PM »
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,

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---

  • Participant
  • Joined in 2017
  • *
  • default avatar
  • Posts: 2
    • View Profile
    • Donate to Member
Re: Dice analyzer machine project
« Reply #87 on: December 02, 2017, 04:10 PM »
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

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #88 on: December 02, 2017, 07:11 PM »
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---

  • Participant
  • Joined in 2017
  • *
  • default avatar
  • Posts: 2
    • View Profile
    • Donate to Member
Re: Dice analyzer machine project
« Reply #89 on: December 02, 2017, 11:02 PM »
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.

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #90 on: December 05, 2017, 05:34 PM »
Btw here was the little half-finished draft of a paper I started writing on the project, just for fun: https://www.donation...er/dicer/DicerC1.pdf

Deozaan

  • Charter Member
  • Joined in 2006
  • ***
  • Points: 1
  • Posts: 9,747
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #91 on: April 26, 2018, 05:00 PM »
That link is a 404. :(

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Dice analyzer machine project
« Reply #92 on: April 26, 2018, 05:03 PM »
Thanks, it didn't make it during the site move.  I've re-uploaded it now, though there is a more recent version of the draft I should save to pdf and upload later.