Package squidpony.squidmath
Class CosmicNumbering
java.lang.Object
squidpony.squidmath.CosmicNumbering
- All Implemented Interfaces:
Serializable
,Noise.Noise2D
,Noise.Noise3D
,Noise.Noise4D
,Noise.Noise6D
public class CosmicNumbering extends Object implements Serializable, Noise.Noise2D, Noise.Noise3D, Noise.Noise4D, Noise.Noise6D
Like a kind of RNG, but fully deterministic in a way that depends on a "connected" double array.
Intended as a way to produce similar values when small changes occur in the connections, while potentially producing
larger changes when the changes are more significant (unlike an RNG or hashing function, which can and should produce
very different output given even slightly different seeds/input). This might be useful to produce procedural story
data that is similar when most of the connected inputs are similar, or for terrain generation/population. This can
produce ints and doubles, and does not produce a different output unless its input is changed (usually by altering a
shared reference to
If you're using this as an arbitrary-dimensional noise algorithm, you may want to also consider
Created by Tommy Ettinger on 5/18/2017.
connections
). Also implements the various Noise
interfaces, which this doesn't
do perfectly but is at least different (it may yield large spans of high or low results, which Simplex and Perlin
noise cannot actually do). Here's a short clip of this in motion.
If you're using this as an arbitrary-dimensional noise algorithm, you may want to also consider
PhantomNoise
,
which has output that looks more like Perlin or Simplex noise but scales to arbitrary dimensions.
Here's a short clip of PhantomNoise in motion.
Created by Tommy Ettinger on 5/18/2017.
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description protected double[]
connections
protected double
effect
static CosmicNumbering
instance
protected int
len
protected long
seed
-
Constructor Summary
Constructors Constructor Description CosmicNumbering()
CosmicNumbering(double[] connections)
CosmicNumbering(long seed, double[] connections)
-
Method Summary
Modifier and Type Method Description double[]
getConnections()
double
getDouble()
Gets a double determined by the current values in the connections, accessible viagetConnections()
.double
getDoubleBase()
Gets a double determined by the current values in the connections, accessible viagetConnections()
.int
getInt()
Gets an int determined by the current values in the connections, accessible viagetConnections()
.double
getNoise(double x, double y)
double
getNoise(double x, double y, double z)
double
getNoise(double x, double y, double z, double w)
double
getNoise(double x, double y, double z, double w, double u, double v)
double
getNoiseWithSeed(double x, double y, double z, double w, double u, double v, long seed)
double
getNoiseWithSeed(double x, double y, double z, double w, long seed)
double
getNoiseWithSeed(double x, double y, double z, long seed)
double
getNoiseWithSeed(double x, double y, long seed)
void
setConnections(double[] connections)
-
Field Details
-
Constructor Details
-
Method Details
-
getConnections
-
setConnections
-
getDoubleBase
Gets a double determined by the current values in the connections, accessible viagetConnections()
. Returns a value between -1.0 and 1.0 (exclusive on 1.0). Used as the basis for other methods in this class.- Returns:
- a double between -1.0 and 1.0; will be the same value until/unless connections change
-
getDouble
Gets a double determined by the current values in the connections, accessible viagetConnections()
. Returns a value between 0.0 and 1.0 (exclusive on 1.0).- Returns:
- a double between 0.0 and 1.0; will be the same value until/unless connections change
-
getInt
Gets an int determined by the current values in the connections, accessible viagetConnections()
. Returns a value in the full range of ints, but is less likely to produce ints close toInteger.MAX_VALUE
orInteger.MIN_VALUE
(expect very few values in the bottom and top quarters of the range).- Returns:
- an int which can be positive or negative; will be the same value until/unless connections change
-
getNoise
- Specified by:
getNoise
in interfaceNoise.Noise2D
-
getNoiseWithSeed
- Specified by:
getNoiseWithSeed
in interfaceNoise.Noise2D
-
getNoise
- Specified by:
getNoise
in interfaceNoise.Noise3D
-
getNoiseWithSeed
- Specified by:
getNoiseWithSeed
in interfaceNoise.Noise3D
-
getNoise
- Specified by:
getNoise
in interfaceNoise.Noise4D
-
getNoiseWithSeed
- Specified by:
getNoiseWithSeed
in interfaceNoise.Noise4D
-
getNoise
- Specified by:
getNoise
in interfaceNoise.Noise6D
-
getNoiseWithSeed
public double getNoiseWithSeed(double x, double y, double z, double w, double u, double v, long seed)- Specified by:
getNoiseWithSeed
in interfaceNoise.Noise6D
-