Need a D20?
Random numbers are often needed in games. They are created by pseudo-random generators that create a sequence of apparently non-related numbers. In fact the next number depends on the last and one use a seed value to set the start number. The sequence will always be the same with the same seed. One common way to initialize the seed value is to use the current system time.
Number in a range
Its common for random functions (ex rand) to return a value between 0 and a very high positive number. To get a value inside a certain range use modulo operator and the initial value of the range.
rand() Considered Harmful - 2013
rand() Considered Harmful - 2019