public class TuringPattern
extends java.lang.Object
Constructor and Description |
---|
TuringPattern() |
Modifier and Type | Method and Description |
---|---|
static void |
addNoise(double[] substance,
int width,
int height,
double multiplier,
Noise.Noise2D noise,
long seed)
Simply adds the result of a noise call, multiplied by the given multiplier, to each point in substance.
|
static void |
addNoise(double[] substance,
int width,
int height,
double multiplier,
Noise.Noise3D noise,
double z,
long seed)
Simply adds the result of a noise call, multiplied by the given multiplier, to each point in substance.
|
static void |
distort(int[][] offsets,
int width,
int height,
Noise.Noise2D noise,
long seed)
Alters the given offset information (as a jagged 2D int array) with the given Noise2D instance and seed.
|
static void |
distort(int[][] offsets,
int width,
int height,
Noise.Noise3D noise,
double z,
long seed)
Alters the given offset information (as a jagged 2D int array) with the given Noise3D instance and seed, allowing
a z position for the 3D component so this can change over time with changing z.
|
static void |
fill(double[][] target,
double[] substance)
Modifies target in-place so it is filled with as much data as possible from substance.
|
static double[] |
initialize(int width,
int height)
Initializes a substance array that can be given to other static methods.
|
static double[] |
initialize(int width,
int height,
IRNG rng)
Initializes a substance array that can be given to other static methods.
|
static double[] |
initialize(int width,
int height,
long seed)
Initializes a substance array that can be given to other static methods.
|
static double[] |
initialize(int width,
int height,
Noise.Noise2D noise,
long seed)
Initializes a substance array that can be given to other static methods.
|
static double[] |
initializeInto(double[] substance)
Refills a substance array that can be given to other static methods.
|
static double[] |
initializeInto(double[] substance,
int width,
int height,
Noise.Noise2D noise,
long seed)
Initializes a substance array that can be given to other static methods.
|
static double[] |
initializeInto(double[] substance,
IRNG rng)
Initializes a substance array that can be given to other static methods.
|
static double[] |
initializeInto(double[] substance,
long seed)
Refills a substance array that can be given to other static methods.
|
static void |
normalize(double[] substance)
Finds the highest and lowest values in the substance array and modifies the whole array so the lowest and highest
values are contracted or expanded to -1.0 and 1.0, respectively, and other values change commensurately.
|
static int[][] |
offsetsCircle(int width,
int height,
double radius)
Pre-calculates the indices into a substance array that will need to be averaged per point in that array for an
activator or inhibitor.
|
static int[][] |
offsetsCircleInto(int[][] offsets,
int width,
int height,
double radius)
Given an offset information array that has been modified and should be returned to its unmodified state, this
uses the given width, height, and radius (which should be the same as what this was originally constructed with)
to modify offsets in-place as if it was freshly-made, even if the array is final.
|
static void |
refit(double[] data)
Modifies the data parameter so no value in it is outside the range -1.0 inclusive to 1.0 exclusive.
|
static double[][] |
reshape(int width,
int height,
double[] substance)
Makes a new 2D double array with the given width and height, using the given substance array for contents.
|
static void |
step(double[] substance,
int[][] activator,
double activation,
int[][] inhibitor,
double inhibition)
Brings together the other methods to advance the substance simulation by one step, modifying substance in-place.
|
static void |
stepPartial(double[] substance,
int[][] activator,
double activation,
int[][] inhibitor,
double inhibition)
Computes the first part of a step, allowing other adjustments to be mixed in before finishing by calling
normalize(double[]) . |
public static double[] initialize(int width, int height)
width
- the width of the substance array; should be consistent throughout callsheight
- the height of the substance array; should be consistent throughout callspublic static double[] initializeInto(double[] substance)
substance
- a 1D double array that will be modified and filled with random valuespublic static double[] initialize(int width, int height, long seed)
width
- the width of the substance array; should be consistent throughout callsheight
- the height of the substance array; should be consistent throughout callsseed
- the long seed to use for the random contentspublic static double[] initializeInto(double[] substance, long seed)
substance
- a 1D double array that will be modified and filled with random valuesseed
- the long seed to use for the random contentspublic static double[] initialize(int width, int height, IRNG rng)
width
- the width of the substance array; should be consistent throughout callsheight
- the height of the substance array; should be consistent throughout callsrng
- the random number generator responsible for producing random double valuespublic static double[] initializeInto(double[] substance, IRNG rng)
substance
- a 1D double array that will be modified and filled with random valuesrng
- the random number generator responsible for producing random double valuespublic static double[] initialize(int width, int height, Noise.Noise2D noise, long seed)
width
- the width of the substance array; should be consistent throughout callsheight
- the height of the substance array; should be consistent throughout callsnoise
- a Noise.Noise2D instance, such as SeededNoise.instance
seed
- the seed to use with the noise generatorpublic static double[] initializeInto(double[] substance, int width, int height, Noise.Noise2D noise, long seed)
width
- the width of the substance array; should be consistent throughout callsheight
- the height of the substance array; should be consistent throughout callsnoise
- a Noise.Noise2D instance, such as SeededNoise.instance
seed
- the seed to use with the noise generatorpublic static void refit(double[] data)
data
- a double array that will be modified in-place so all values in it will be between -1.0 and 1.0public static int[][] offsetsCircleInto(int[][] offsets, int width, int height, double radius)
offsets
- an offset information array that should have been produced by offsetsCircle(int, int, double)
and may have been distortedwidth
- the width of the substance array; should be consistent throughout callsheight
- the height of the substance array; should be consistent throughout callsradius
- the radius of the circle tostep(double[], int[][], double, int[][], double)
public static int[][] offsetsCircle(int width, int height, double radius)
width
- the width of the substance array; should be consistent throughout callsheight
- the height of the substance array; should be consistent throughout callsradius
- the radius of the circle tostep(double[], int[][], double, int[][], double)
public static void distort(int[][] offsets, int width, int height, Noise.Noise2D noise, long seed)
offsets
- a jagged 2D int array as produced by offsetsCircle(int, int, double)
; will be modified!width
- the width of the full area that will be used by the TuringPatternheight
- the height of the full area that will be used by the TuringPatternnoise
- a Noise2D instance, such as SeededNoise.instance
, that will be used to alter offsetsseed
- a seed for the Noise2Dpublic static void distort(int[][] offsets, int width, int height, Noise.Noise3D noise, double z, long seed)
offsets
- a jagged 2D int array as produced by offsetsCircle(int, int, double)
; will be modified!width
- the width of the full area that will be used by the TuringPatternheight
- the height of the full area that will be used by the TuringPatternnoise
- a Noise3D instance, such as SeededNoise.instance
, that will be used to alter offsetsz
- a z position to be given to the Noise3D along with a point's x and yseed
- a seed for the Noise3Dpublic static void step(double[] substance, int[][] activator, double activation, int[][] inhibitor, double inhibition)
refit(double[])
,
and the activator and inhibitor should have been produced by calls to an offsets method like
offsetsCircle(int, int, double)
, with the same width and height passed to initialize (or if you used
refit, the length of the substance array should be equal to width times height). The activation and inhibition
parameters should be very small (larger numbers will cause more significant jumps in a simulation, but may be
better for single generations; neither amount should have an absolute value larger than 0.1 in general), and
inhibition should have the opposite sign of activation.substance
- as produced by initialize; will be modified!activator
- as produced by an offsets methodactivation
- the small double amount to use when the activator is dominant; should usually be positiveinhibitor
- as produced by an offsets methodinhibition
- the small double amount to use when the inhibitor is dominant; should usually be negativepublic static void stepPartial(double[] substance, int[][] activator, double activation, int[][] inhibitor, double inhibition)
normalize(double[])
. A sample adjustment would be
addNoise(double[], int, int, double, Noise.Noise2D, long)
. This is probably not very useful yet.substance
- as produced by initialize; will be modified!activator
- as produced by an offsets methodactivation
- the small double amount to use when the activator is dominant; should usually be positiveinhibitor
- as produced by an offsets methodinhibition
- the small double amount to use when the inhibitor is dominant; should usually be negativestep, which is preferred to this method
public static void addNoise(double[] substance, int width, int height, double multiplier, Noise.Noise2D noise, long seed)
substance
- as produced by initialize; will be modified!width
- the width of the substance array; should be consistent throughout callsheight
- the height of the substance array; should be consistent throughout callsmultiplier
- multiplied with each noise call, so noise (usually too significant) can have its effect reducednoise
- a Noise2D instance, such as SeededNoise.instance
seed
- a seed for the Noise2Dpublic static void addNoise(double[] substance, int width, int height, double multiplier, Noise.Noise3D noise, double z, long seed)
substance
- as produced by initialize; will be modified!width
- the width of the substance array; should be consistent throughout callsheight
- the height of the substance array; should be consistent throughout callsmultiplier
- multiplied with each noise call, so noise (usually too significant) can have its effect reducednoise
- a Noise3D instance, such as SeededNoise.instance
z
- a z position to be given to the Noise3D along with a point's x and yseed
- a seed for the Noise3Dpublic static void normalize(double[] substance)
substance
- a substance array, as produced by initialize, will be modified!public static double[][] reshape(int width, int height, double[] substance)
width
- the width of the 2D array to produce; must be 1 or greaterheight
- the height of the 2D array to produce; must be 1 or greatersubstance
- a substance array as produced by initialize and modified by steppublic static void fill(double[][] target, double[] substance)
target
- a non-null, non-empty 2D double array; will be modified!substance
- a substance array as produced by initialize and modified by stepCopyright © Eben Howard 2012–2022. All rights reserved.