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 long
state
-
Constructor Summary
-
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.
-
Field Details
-
Constructor Details
-
Method Details
-
getState
Description copied from interface:StatefulRandomness
Get the current internal state of the StatefulRandomness as a long.- Specified by:
getState
in interfaceStatefulRandomness
- Returns:
- the current internal state of this object.
-
setState
Description copied from interface:StatefulRandomness
Set the current internal state of this StatefulRandomness with a long.- Specified by:
setState
in interfaceStatefulRandomness
- Parameters:
state
- a 64-bit long. You should avoid passing 0, even though some implementations can handle that.
-
next
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 interfaceRandomnessSource
- Parameters:
bits
- the number of bits to be returned- Returns:
- the integer containing the appropriate number of bits
-
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 interfaceRandomnessSource
- 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 interfaceRandomnessSource
- Specified by:
copy
in interfaceStatefulRandomness
- Returns:
- a copy of this RandomnessSource
-