Class FlawedRandomness.AddRotate

java.lang.Object
squidpony.squidmath.FlawedRandomness.AddRotate
All Implemented Interfaces:
Serializable, FlawedRandomness, IFlawed, RandomnessSource, StatefulRandomness
Enclosing interface:
FlawedRandomness

public static class FlawedRandomness.AddRotate
extends Object
implements FlawedRandomness, StatefulRandomness
A flawed randomness source that adds a rotation of its state, to its state, every generation. The rotation amount is also determined by state. This one's probably pretty bad; I don't really know how bad it will be to a human observer, but it also depends on what cycle it starts in. The state probably shouldn't ever be 0, since this will only produce 0 after its state becomes 0. Of course, this is flawed, so it can become 0 in the course of normal generation.
See Also:
Serialized Form
  • Nested Class Summary

    Nested classes/interfaces inherited from interface squidpony.squidmath.FlawedRandomness

    FlawedRandomness.AddRotate, FlawedRandomness.BigCounter
  • Field Summary

    Fields 
    Modifier and Type Field Description
    long state  
  • Constructor Summary

    Constructors 
    Constructor Description
    AddRotate()  
    AddRotate​(long state)  
  • Method Summary

    Modifier and Type Method Description
    FlawedRandomness.AddRotate copy()
    Produces a copy of this RandomnessSource that, if next() and/or nextLong() are called on this object and the copy, both will generate the same sequence of random numbers from the point copy() was called.
    long getState()
    Get the current internal state of the StatefulRandomness as a long.
    int next​(int bits)
    Using this method, any algorithm that might use the built-in Java Random can interface with this randomness source.
    long nextLong()
    Using this method, any algorithm that needs to efficiently generate more than 32 bits of random data can interface with this randomness source.
    void setState​(long state)
    Set the current internal state of this StatefulRandomness with a long.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • getState

      public long getState()
      Description copied from interface: StatefulRandomness
      Get the current internal state of the StatefulRandomness as a long.
      Specified by:
      getState in interface StatefulRandomness
      Returns:
      the current internal state of this object.
    • setState

      public void setState​(long state)
      Description copied from interface: StatefulRandomness
      Set the current internal state of this StatefulRandomness with a long.
      Specified by:
      setState in interface StatefulRandomness
      Parameters:
      state - a 64-bit long. You should avoid passing 0, even though some implementations can handle that.
    • next

      public int next​(int bits)
      Description copied from interface: RandomnessSource
      Using this method, any algorithm that might use the built-in Java Random can interface with this randomness source.
      Specified by:
      next in interface RandomnessSource
      Parameters:
      bits - the number of bits to be returned
      Returns:
      the integer containing the appropriate number of bits
    • nextLong

      public long nextLong()
      Description copied from interface: RandomnessSource
      Using this method, any algorithm that needs to efficiently generate more than 32 bits of random data can interface with this randomness source. Get a random long between Long.MIN_VALUE and Long.MAX_VALUE (both inclusive).
      Specified by:
      nextLong in interface RandomnessSource
      Returns:
      a random long between Long.MIN_VALUE and Long.MAX_VALUE (both inclusive)
    • copy

      Description copied from interface: RandomnessSource
      Produces a copy of this RandomnessSource that, if next() and/or nextLong() are called on this object and the copy, both will generate the same sequence of random numbers from the point copy() was called. This just needs to copy the state so it isn't shared, usually, and produce a new value with the same exact state.
      Specified by:
      copy in interface RandomnessSource
      Specified by:
      copy in interface StatefulRandomness
      Returns:
      a copy of this RandomnessSource