Difference between revisions of "Rn2"
Jump to navigation
Jump to search
(Creating these pages because I've been misreading rn1 every single time.) |
m (minor additions.) |
||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:rn2}} | {{DISPLAYTITLE:rn2}} | ||
rn2(x)<ref>[[rnd.c#rn2]]</ref> 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). | rn2(x)<ref>[[rnd.c#rn2]]</ref> 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== | ==References== |
Revision as of 18:19, 8 January 2011
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.