Repository
https://gist.github.com/themarkymark-steem/09ab5f94bab17c705350781182094042
Introduction
I was curious how fair Magic Dice really is. They claim to be provably fair and have a script to check an individual bet. I wanted to check real-world results across thousands of bets.
Process
- Choose Sample Set
- Collect Data
- Parse Data
- Calculate Results
Choose Sample Set
While I could parse every type of bet, I chose to focus only on 50/50 bets (technically 49%). This makes data collection and parsing very simple and would give me a very good answer if Magic Dice is truly fair.
Collect Data
I wrote a script (see above gist) that goes through the entire account history for magicdice
and creates a python generator that can be later iterated through.
Parse Data
Parsing data required two steps.
- Find bets that are 50/50 bets.
- Determine if the bet was a Win or a Loss.
The first part was easy, I just looked for Multiplier: 2.00
in a memo from @magicdice to another user. This would identify any bet successful memo that had even money.
The second part simply checks if You have won
or You lost
is in the memo. The result of this test is stored in either the win
or loss
variable.
Calculate Results
All that is left is to add up the Wins and Losses to find the total amount of bets, then divide this number by the number of wins. This will give me a win percentage for even money bets.
Results
The final result was 71913 Wins and 74906 Loses for a total of 146,819 bets using even odds. If we then divide the wins by the loses the result is 0.489807 or 48.98%. When you factor in the 2% house advantage, this is right on the money.
Conclusion
As far as I can see, Magic Dice's claim to be provable fair is in fact true. Over a very large sample of games (almost 150,000), the win rate is very close to the 49% Win Chance claimed for an even money bet. Magic Dice does provide another script to test individual bets but as stated above I wanted to see for myself based on actual bets.
Tools and Scripts
I used Python and @holger80's fantastic Beem library to conduct this analysis.
What I could have done better
This test only verifies a subset of the bets, the even money bets. I believe this covers a very large sample of the games played, but a more in-depth test would collect data for all bets and compare the results to the stated odds. I don't think this is necessary or productive but would provide a more comprehensive analysis.