

PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 
Object com.internationalnetwork.math.random.XORShiftZ
public class XORShiftZ
The XORShiftZ
class is a consistent alternative to Java's
builtin java.util.Random class. Although it doesn't offer all the
same methods, the key methods are provide simple and reliable longsequence
pseudorandom number generation. Steps have been taken in this
algorithm to minimize processor overhead, and to ensure the sequence is not
repeated for as long as possible (all pseudorandom number generators
suffer from the same problem in that the generated sequences eventually
repeat).
This is a modified version of the XOR Shift algorithm because an additional bit is altered after the first three bit shifts is complete. This is necessary to ensure that values with all bits set or all bits cleared won't be excluded from the sequence (which is one of the shortcomings of any XOR Shift algorithms that rely exclusively on XOR operations and a nonzero seed).
The algorithm itself uses a series of three eXclusive OR instructions combined with bitwise Shift operations, all acting on the current seed which doubles as the random number. Unlike more complicated math operations, which are typically utilized by other pseudorandom number generators, these operations are very fast because they consume fewer CPU cycles (this may be important to game developers, or other developers who are developing other timesensitive applications).
Field Summary  

static String 
VERSION
Version number of this Package (readonly). 
Constructor Summary  

XORShiftZ(long seed)
Instantiate a new XORShiftZ object with the specified seed. The resulting pseudorandom number sequence is of "medium quality" which is an improvement over the default java.util.Random class. 
Method Summary  

long 
currentLong()
Return the current random number. 
int 
nextInt()
Return the next random number. 
long 
nextLong()
Return the next random number. 
Methods inherited from class Object 

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
Field Detail 

public static final String VERSION
Constructor Detail 

public XORShiftZ(long seed)
seed
 Seed that the random number generator is initialized with.Method Detail 

public long currentLong()
public int nextInt()
public long nextLong()


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 