Games-Dice-Probability

 view release on metacpan or  search on metacpan

lib/Games/Dice/Probability.pm  view on Meta::CPAN

505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
    (3d6/2) * 2d4
 
or:
 
    mid20 + (mid6+1)
 
When the object is created, the full distribution is calculated using as many
shortcuts and optimizations as possible.  These include reducing logic based on
certain values of n, only calculating half of any standard distribution, and
using an identity to create the other "mirrored" half of the distribution.
Also, large-number math is reduced by using formulae that reduce the
calculations to much smaller numbers, including the very efficient binomial
coefficient method in Math::Symbolic::AuxFunctions.  Lastly, each node's
distribution calculation and multi-node combined distribution calculation can
be Memoized, negating nearly all compute cycles for future identical
calculations.  All of these combined create a very sleek and fast method of
calculating dice distributions.
 
Memoization for calculations can be disabled at the time you declare use of
this module by passing an argument:



( run in 0.479 second using v1.01-cache-2.11-cpan-2b0bae70ee8 )