Tuesday, July 10, 2012

Cross posted at http://steamunderground.blogspot.com/

At the core of any game application is going to be a random number generator.  I found out that using .Net's base random class is fine for a one off or limited set of random numbers needing to generated, but once you start beating on the .Net random class you start seeing some funky results.  So for a little game demo I'm working on I put together a static class that generates random numbers based on the System.Security.Cryptography.RNGCryptoServiceProvider which seems work well even if it is a tad slow.

Here is the class.  Note the static method GetD6Successes.  This is meant to mimic the "exploding" D6 die pool mechanic used in some table top RPG's.  I like the concept as in theory a lone peasant has a chance, though a very very very small chance, of slaying a dragon with this mechanic.  Let me know what you think.