API:RNG: Difference between revisions
Jump to navigation
Jump to search
Bruce Pascoe (talk | contribs) Created page with "{{subst:objecttemp|preamble=Constructs a new instance of the Sphere pseudorandom number generator. The '''RNG''' object uses the xoroshiro128+ algorithm, providing high-quali..." |
Bruce Pascoe (talk | contribs) Add some subheadings |
||
| (5 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{ | {{DISPLAYTITLE:new RNG()}} | ||
The '''<tt>RNG()</tt> constructor''' initializes a new instance of the pseudorandom number generator, seeded using the current time and date. | |||
===== Usage ===== | |||
''rng_object'' = '''new RNG'''(); | |||
__TOC__ | |||
== API Information == | |||
=== Description === | |||
<tt>'''new RNG()'''</tt> initializes a new instance of the built-in pseudorandom number generator, seeded based on the current time and date. Unlike <tt>Math.random()</tt> which uses a very basic linear generator, Sphere uses the ''xoroshiro128+'' algorithm, providing games with a very high-quality source of pseudorandom numbers. | |||
To control the initial state of the generator, use <tt>[[API:RNG.fromSeed|RNG.fromSeed()]]</tt> or <tt>[[API:RNG.fromState|RNG.fromState()]]</tt>. | |||
=== Properties === | |||
<tt> | |||
* [[API:RNG::state|RNG::state]] | |||
</tt> | |||
=== Methods === | |||
==== Static Methods ==== | |||
<tt> | |||
* [[API:RNG.fromSeed|RNG.fromSeed()]] | |||
* [[API:RNG.fromState|RNG.fromState()]] | |||
</tt> | |||
==== Instance Methods ==== | |||
<tt> | |||
* [[API:RNG::next|RNG::next()]] | |||
</tt> | |||
[[Category:Sphere 2 API]] | |||
Latest revision as of 04:08, 12 August 2017
The RNG() constructor initializes a new instance of the pseudorandom number generator, seeded using the current time and date.
Usage
rng_object = new RNG();
API Information
Description
new RNG() initializes a new instance of the built-in pseudorandom number generator, seeded based on the current time and date. Unlike Math.random() which uses a very basic linear generator, Sphere uses the xoroshiro128+ algorithm, providing games with a very high-quality source of pseudorandom numbers.
To control the initial state of the generator, use RNG.fromSeed() or RNG.fromState().
Properties
Methods
Static Methods
Instance Methods