Difference between revisions of "Random2"

From CrawlWiki
Jump to: navigation, search
m (Removed broken link)
Line 3: Line 3:
 
'''random2(''int max'')'''
 
'''random2(''int max'')'''
  
and returns a random number from 0 to ''max-1''. Therefore, '''random2(2)''' returns either 0 or 1, which is how the '''[[coinflip]]''' function is defined.
+
and returns a random number from 0 to ''max-1''. Therefore, '''random2(2)''' returns either 0 or 1, which is how the '''coinflip''' function is defined.
  
 
'''random2''' is defined in [http://git.develz.org/?p=crawl.git;a=blob;f=crawl-ref/source/random.cc 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.
 
'''random2''' is defined in [http://git.develz.org/?p=crawl.git;a=blob;f=crawl-ref/source/random.cc 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.
  
 
[[Category:Source]]
 
[[Category:Source]]

Revision as of 23:56, 26 May 2014

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

random2(int max)

and returns a random number from 0 to max-1. 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.