Is the Ultimate Dice Roller _Mathematically_ Fair?
Hey everyone,
The other day, @ecoinstant posed an excellent question about the Ultimate Dice Roller: we know it's provably fair, but is it mathematically fair? In other words, over a large number of rolls, does it produce a statistically even distribution?
I thought that was a great question to dig into. To test it, I added some scripts to the project's GitHub repository to simulate rolling 3d6 thousands of time. A 3d6 roll is common for generating character stats in old-school D&D, and it should produce a nice bell curve distribution of results from 3 to 18.
Test 1: 100 Rolls, As Fast as Possible
First, I had the script roll 100 times as quickly as possible. Because the rolls happen so fast, they all use the same seed data from the same Hive block. The result was, as expected, not very random at all.
Test 2: 100 Rolls, With a Delay
Next, I had the script wait a few seconds between each of the 100 rolls. This pause allows the blockchain to produce new blocks, ensuring that each roll gets a new, unique seed (server seed, client seed, and nonce). The result was a much better, more varied distribution.
Test 3: 5,000 Rolls
Finally, for the ultimate test, I had the script roll the dice 5,000 times. I did this as fast as possible because waiting a few seconds for each roll would have taken over four hours (5,000 rolls x 3 seconds/roll ≈ 4.16 hours). The script rapidly requested rolls, and the server's "salting" mechanism ensured each roll was still unique even if the block data was the same.
The final chart speaks for itself.
With a large enough sample size, the dice roller produces a beautiful, statistically fair bell curve, right on the money. So, the answer is yes, the Ultimate Dice Roller is not only provably fair but mathematically fair as well.
If this kind of statistical analysis interests you, feel free to take a look at the scripts directory in the GitHub repo to see how the tests were run and the plots were generated.
As always,
Michael Garcia a.k.a. TheCrazyGM
Leave Is the Ultimate Dice Roller _Mathematically_ Fair? to:
Read more #dev posts
Best Posts From Michael Garcia
We have not curated any of thecrazygm's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From Michael Garcia
- Playing Traffic Cop, Part Two: When the Cop Pulls Over Everybody
- Moon Has Moved to Finland
- A Good Week for Small Hive-Engine Fixes
- An Accidental Stress Test for Hive-Engine Data Integrity
- Fixing Data Integrity Issues in Hive-Engine Nodes
- The Final Chapter: dCity's 70,000 HIVE Claimdrop Has Been Distributed!
- Anther v0.1.0: A Modern Go SDK for Building on Hive
- Redesigning the Project Builder (GET FEATURED!)
- HiveTools Workbench: A Week of Polish, Pollen, and Splinterlands Wallets
- Pollen: A Safer, Cleaner Path Forward for Hive JavaScript Developers