Difference between revisions of "Rn2"
Jump to navigation
Jump to search
m |
|||
Line 16: | Line 16: | ||
[[Category:Random number functions]] | [[Category:Random number functions]] | ||
+ | {{nethack-343}} |
Revision as of 02:38, 21 December 2015
rn2(x)[1] is a pseudo-random number function used in NetHack when a result should be unweighted. The range of values is between 0 and x-1 inclusive (that is, 0 ≤ rn2(x) < x).
For example, to simulate a percentage chance:
if (rn2(100) < chance) { ... }
Also,
!rn2(x)
is true with a 1/x probability.
See also rn1.
References
This page may need to be updated for the current version of NetHack.
It may contain text specific to NetHack 3.4.3. Information on this page may be out of date.
Editors: After reviewing this page and making necessary edits, please change the {{nethack-343}} tag to the current version's tag or {{noversion}} as appropriate.