Difference between revisions of "Template:RNG"

From RimWorld Wiki
Jump to navigation Jump to search
m (Page Specific.)
(added pseydo)
Line 1: Line 1:
 
<!--DISCLAIMER:I restrict my RNG calculation time to 0.5 secs, no expensive parserfunctions please!-->
 
<!--DISCLAIMER:I restrict my RNG calculation time to 0.5 secs, no expensive parserfunctions please!-->
 
{{impressive}}
 
{{impressive}}
Generic random number:<onlyinclude>
+
Generic pseudo-random number:<onlyinclude>
{{#expr:(({{{seed|0}}}+0)^2*731+{{REVISIONTIMESTAMP}})*327 mod {{{limit|100}}}}}
+
{{#expr:(({{{seed|0}}}+731)^2-{{{seed|0}}}+{{REVISIONTIMESTAMP}})*327 mod {{{limit|100}}}}}
 
</onlyinclude>
 
</onlyinclude>
 
<!--More cases coming soon!-->
 
<!--More cases coming soon!-->

Revision as of 03:07, 13 December 2016

Generic pseudo-random number: 79

Generated numbers:

Seed 1 limit 30: 3
Seed 2 limit 30: 21
Seed 1: 53

Description

This template is used to generate random numbers in a relatively short time.

Usage

Type {{RNG}} on the page to assume a seed of 0 and a limit of 100.

NOTE: Setting a limit value to something greater than 1 000 000 WILL have an effect on the randomness of the result. Use two {{RNG}} templates instead.
{{RNG
|seed=(number)            -->Makes RNGs with different seeds unique to each other.
|limit=(number)           -->Restricts the RNG to produce only numbers from 1 to limit.
}}

Example:

{{RNG
|seed=1234
|limit=5000}}

results in: 1189