rn2

From NetHackWiki
Revision as of 21:07, 29 May 2011 by 99.239.146.253 (talk) (cat)
Jump to navigation Jump to search

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) { ... }

See also rn1.

References

This page is a stub. Should you wish to do so, you can contribute by expanding this page.