Skip to content

Joaqim/balanced-dice-avr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Balanced Dice

⚠️ WIP ⚠️

This Library uses a deck of cards to simulate two 6-sided dice being rolled.

The Deck consists of 36 pairs of Dice, ranging from 2 to 12 in value, with for instance 2 and 12 only having one possible pair each (1+1 = 2 and 6 + 6 = 12).

The Card with value 7 has 6 possible pairs: 1+6,2+5,3+4 and the reverse 6+1,5+2,4+3.

The output tries to simulate a more fitting normal distribution of expected results even with fewer dice rolls.

Methodology involves calculating probability of drawing a value of previous rolls and changing the outcome afterwards. The deck is shuffled when there are only 12 cards left in the deck, allowing occasionally successive rolls of 2's and 12's to occur.

Histograms

Each is a sample of 50 dice being thrown.

Balanced Dice:

                           _                           
                          | |                          
                      _   | |   _                      
                     | |  | |  | |                     
                     | |  | |  | |                     
                     | |  | |  | |                     
            _        | |  | |  | |                     
           | |   _   | |  | |  | |                     
           | |  | |  | |  | |  | |   _         _       
       _   | |  | |  | |  | |  | |  | |   _   | |      
  _   | |  | |  | |  | |  | |  | |  | |  | |  | |   _  
  -    -    -    -    -    -    -    -    -    -    -
  2    3    4    5    6    7    8    9   10   11   12

NOTE: In this instance, 2 and 12 each have been thrown once, those columns having value of 1.

Unbalanced Dice, naive implementation:

                      _
                     | |
                     | |                  _
                     | |   _    _    _   | |
       _    _        | |  | |  | |  | |  | |
      | |  | |       | |  | |  | |  | |  | |
      | |  | |       | |  | |  | |  | |  | |
      | |  | |       | |  | |  | |  | |  | |        _
      | |  | |   _   | |  | |  | |  | |  | |   _   | |
      | |  | |  | |  | |  | |  | |  | |  | |  | |  | |
  -    -    -    -    -    -    -    -    -    -    -
  2    3    4    5    6    7    8    9   10   11   12

References

Heres is the reference I followed in implementation: Colonist.io - Designing Balanced Dice

TODO

  • Consider using std::normal_distribution
  • Show Test of Fitness for normal distribution.
  • Test if 16-bit as seed is enough to generate float value (0.f - 1.f), and if it would be valid to overlap some bits to use same seed twice, i.e pass a 16-bit seed and use as two distinct 8-bit seed in two different cases.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published