-
Notifications
You must be signed in to change notification settings - Fork 30
Random Number Generation
Chris3606 edited this page Oct 20, 2018
·
8 revisions
GoRogue relies on the excellent Troschuetz.Random library for fast and easy random number generation. The currentdocumentation can be found here.
Code examples in this section show only code in the Main function. The code provided assumes that the following "using" statements are at the top of the code file:
using GoRogue.Random;
Generating random numbers in a default manner is fairly easy, since a default RNG is provided.
A public (and settable) property is provided that allows the RNG that is considered to be. It also has a default value, (details BELOW) This provides a convenient, succinct way to generate random numbers:
// Gets a random integer between 1 and 6, inclusive
int random1 = SingletonRandom.DefaultRNG.Next(1, 6);
// When only a max is specified, the minimum is implicitly 0.
// Thus, here we get a random number between 0 and 6, inclusive.
int random2 = SingletonRandom.DefaultRNG.Next(6);
- Home
- Getting Started
- GoRogue 1.0 to 2.0 Upgrade Guide
- Grid System
- Dice Rolling
- Effects System
- Field of View
- Map Generation (docs coming soon)
- Map View System
- Pathfinding (docs coming soon)
- Random Number Generation (docs coming soon)
- Sense Mapping (docs coming soon)
- Spatial Maps (docs coming soon)
- Utility/Miscellaneous (docs coming soon)