Package squidpony.squidmath
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 longstate -
Constructor Summary
-
Method Summary
Modifier and Type Method Description FlawedRandomness.AddRotatecopy()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.longgetState()Get the current internal state of the StatefulRandomness as a long.intnext(int bits)Using this method, any algorithm that might use the built-in Java Random can interface with this randomness source.longnextLong()Using this method, any algorithm that needs to efficiently generate more than 32 bits of random data can interface with this randomness source.voidsetState(long state)Set the current internal state of this StatefulRandomness with a long.
-
Field Details
-
Constructor Details
-
Method Details
-
getState
Description copied from interface:StatefulRandomnessGet the current internal state of the StatefulRandomness as a long.- Specified by:
getStatein interfaceStatefulRandomness- Returns:
- the current internal state of this object.
-
setState
Description copied from interface:StatefulRandomnessSet the current internal state of this StatefulRandomness with a long.- Specified by:
setStatein interfaceStatefulRandomness- Parameters:
state- a 64-bit long. You should avoid passing 0, even though some implementations can handle that.
-
next
Description copied from interface:RandomnessSourceUsing this method, any algorithm that might use the built-in Java Random can interface with this randomness source.- Specified by:
nextin interfaceRandomnessSource- Parameters:
bits- the number of bits to be returned- Returns:
- the integer containing the appropriate number of bits
-
nextLong
Description copied from interface:RandomnessSourceUsing 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:
nextLongin interfaceRandomnessSource- Returns:
- a random long between Long.MIN_VALUE and Long.MAX_VALUE (both inclusive)
-
copy
Description copied from interface:RandomnessSourceProduces 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:
copyin interfaceRandomnessSource- Specified by:
copyin interfaceStatefulRandomness- Returns:
- a copy of this RandomnessSource
-