Difference between revisions of "API:RNG"

From Spherical
Jump to: navigation, search
(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...")
 
(Initial draft of RNG constructor documentation)
Line 1: Line 1:
{{subst:objecttemp|preamble=Constructs a new instance of the Sphere pseudorandom number generator.  The '''RNG''' object uses the xoroshiro128+ algorithm, providing high-quality pseudorandom numbers.|function=RNG|object=RNG|returns=A new ```RNG``` instance.|params=none}}
+
Constructs a new instance of the pseudorandom number generator.
 +
 
 +
===== Usage =====
 +
 
 +
  rng_obj = '''new RNG'''();
 +
 
 +
__TOC__
 +
 
 +
== Description ==
 +
 
 +
The <tt>'''RNG'''</tt> constructor initializes a new instance of the Sphere random 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, you should use one of <tt>[[API:RNG.fromSeed|RNG.fromSeed()]]</tt> or <tt>[[API:RNG.fromState|RNG.fromState()]]</tt> instead.
 +
 
 +
== 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>

Revision as of 04:35, 8 August 2017

Constructs a new instance of the pseudorandom number generator.

Usage
rng_obj = new RNG();

Description

The RNG constructor initializes a new instance of the Sphere random 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, you should use one of RNG.fromSeed() or RNG.fromState() instead.

Properties

Methods

Static Methods

Instance Methods