Random2

From CrawlWiki
Revision as of 18:12, 5 January 2022 by Ge0ff (talk | contribs) (Expand a bit)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

random2 is a function used in Crawl's code to select a random number. It is defined in the following way:

random2(int max)

and returns a random number from 0 to max-1, which is 1dmax - 1 in the dice notation. Therefore, random2(2) returns either 0 or 1, which is how the coinflip function is defined.

random2 is defined in random.cc, along with many other important random functions. Most calculations of damage, quantities, and properties, will use it, so wiki editors who are looking into the source to find out these values should familiarise themself with the function.