Difference between revisions of "API:RNG"

From Spherical
Jump to: navigation, search
(Improve documentation conventions a bit)
Line 1: Line 1:
{{DISPLAYTITLE:RNG Constructor}}
+
{{DISPLAYTITLE:new RNG()}}
  
Constructs a new instance of the pseudorandom number generator.
+
The '''<tt>RNG()</tt> constructor''' initializes a new instance of the pseudorandom number generator, seeded using the current time and date.
  
 
===== Usage =====
 
===== Usage =====
  
  rng_obj = '''new RNG'''();
+
  ''rng_object'' = '''new RNG'''();
  
 
__TOC__
 
__TOC__
Line 11: Line 11:
 
== Description ==
 
== 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.
+
<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>.
 
To control the initial state of the generator, use <tt>[[API:RNG.fromSeed|RNG.fromSeed()]]</tt> or <tt>[[API:RNG.fromState|RNG.fromState()]]</tt>.

Revision as of 15:01, 8 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();

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