Package squidpony.squidmath

A very broad package containing random number generators, geometry tools, data structures, and noise functions.
  • Interface Summary 
    Interface Description
    CrossHash.IHasher
    An interface that can be used to move the logic for the hashCode() and equals() methods from a class' methods to an implementation of IHasher that certain collections in SquidLib can use.
    FlawedPointHash
    An interface for point hashes that are statistically biased, as well as a holder for inner classes that implement this.
    FlawedRandomness
    An interface to indicate a RandomnessSource that is intentionally flawed to create output patterns where a truly random sequence would have none.
    IDistribution
    A way to take an IRNG and get one or more random numbers from it to produce a double in some statistical distribution, such as Gaussian (also called the normal distribution), exponential, or various simpler schemes that don't have common mathematical names.
    IFlawed
    An empty marker interface to indicate that an implementor has known or intentional issues with a key property of its functionality.
    IPointHash
    An interface for "point hashes", that is, functions that produce usually-unique integer results given multiple integer inputs.
    IRNG
    Interface for full-featured random number generators to implement (it does more than, and includes all of, RandomnessSource).
    IStatefulRNG
    Simply groups the two interfaces IRNG and StatefulRandomness so some implementations of IRNG can have their states read from and written to.
    Noise.Noise1D  
    Noise.Noise2D  
    Noise.Noise3D  
    Noise.Noise4D  
    Noise.Noise6D  
    RandomnessSource
    This interface defines the interactions required of a random number generator.
    SkippingRandomness
    A simple interface for RandomnessSources that have the additional capability to skip forward or backward in their generated number stream.
    StatefulRandomness
    A simple interface for RandomnessSources that have the additional property of a state that can be re-set.
  • Class Summary 
    Class Description
    AbstractRNG
    A helper class for implementing IRNG without so much busy-work.
    Arrangement<K>
    A bi-directional mapping of objects to positions in an ordering (which this generates), and vice versa.
    AStarSearch
    Performs A* search to find the shortest path between two Coord points.
    BalancedPermutations
    Based on Martin Roberts' blog post about blue noise point sets, this class generates "balanced" permutations of a specific size with good performance.
    BasicRandom32
    A low-quality but very fast RNG that has no apparent visual artifacts here; uses Mark Overton's CMR subcycle generator type, but modified to be especially GWT-friendly.
    BasicRandom64
    A high-quality and very fast RNG that has no apparent visual artifacts here; uses Mark Overton's CMR subcycle generator type, with a multiplication on the output.
    BathtubDistribution
    An IDistribution that produces results between 0.0 inclusive and 1.0 exclusive, but is much more likely to produce results near 0.0 or 1.0, further from 0.5.
    BinaryHeap<T extends BinaryHeap.Node>
    A binary heap that stores nodes which each have a double value and are sorted either lowest first or highest first.
    BinaryHeap.Node
    A binary heap node.
    BlueNoise
    Provides access to a precalculated, tiling plane of 2D blue noise, that is, noise without high-frequency components, as well as seeded modifications to that tiling blue noise plane that make it have even fewer patterns.
    Bresenham
    Provides a means to generate Bresenham lines in 2D and 3D.
    CellularAutomaton
    Created by Tommy Ettinger on 7/3/2017.
    ChaosRNG
    An RNG that cannot be seeded and should be fairly hard to predict what it will return next.
    ClassicNoise
    "Classic Perlin" noise, as opposed to the Simplex Noise also created by Ken Perlin (which is produced by SeededNoise; both can be produced by FastNoise).
    CombinationGenerator<T>
    Combination generator for generating all combinations of a given size from the specified set of elements.
    Coord
    A 2D coordinate with (constant) x and y fields.
    Coord3D
    Generic three dimensional coordinate class.
    CoordDouble
    Coord using double values for x and y instead of int.
    CoordPacker
    Provides static methods to encode Coords as single primitive ints in various ways, hence the namesake, but also provides advanced methods to encode 2D arrays of various sorts produced by SquidLib in extremely memory-efficient representations, and decode those representations to various types of 2D array on-demand.
    CosmicNumbering
    Like a kind of RNG, but fully deterministic in a way that depends on a "connected" double array.
    CriticalRNG
    A type of RNG that can generate values larger or smaller than the normal maximum or minimum, based on a modifier.
    CrossHash
    64-bit and 32-bit hashing functions that we can rely on staying the same cross-platform.
    CrossHash.Curlup
    Like Yolk, this is a class for hash functors, each an object with a 64-bit long seed.
    CrossHash.Hive
    A reasonably-fast hashing function that passes some of SMHasher's quality tests, but neither critically fails nor overwhelmingly succeeds the full SMHasher test battery.
    CrossHash.Lightning
    A quick, simple hashing function that seems to have good results.
    CrossHash.Mist
    A whole cluster of Wisp-like hash functions that sacrifice a small degree of speed, but can be built with up to 128 bits of salt values that help to obscure what hashing function is actually being used.
    CrossHash.Water
    A fairly fast hashing algorithm in general, Water performs especially well on large arrays, and passes SMHasher's newest and most stringent version of tests.
    CrossHash.Wisp
    The fastest hash in CrossHash, with middling quality.
    CrossHash.Yolk
    Like Mist, this is a class for hash functors, each an object with a 64-bit long seed, but it uses about the same algorithm as CrossHash.Water instead of the older, less-robust style Mist uses.
    CurvedBoundedDistribution
    An IDistribution that allows a parameter to determine how many calls to IRNG.nextDouble() to make and average whenever a double is requested.
    DDALine
    A fixed-point line-drawing algorithm that should have good performance; may be useful for LOS.
    DeckRNG
    An RNG variant that has 16 possible grades of value it can produce and shuffles them like a deck of cards.
    DelaunayTriangulator
    A Java implementation of an incremental 2D Delaunay triangulation algorithm.
    DelaunayTriangulator.Edge  
    DelaunayTriangulator.Triangle  
    DharmaRNG
    An alteration to a RandomnessSource that attempts to produce values that are perceived as fair to an imperfect user.
    Dice
    Class for emulating various traditional RPG-style dice rolls.
    DistributedRNG
    An implementation of IRNG that allows specifying a distribution for all random numbers it produces via a IDistribution.SimpleDistribution value.
    DiverRNG
    A very-high-quality StatefulRandomness that is the fastest 64-bit generator in this library that passes statistical tests and is one-dimensionally equidistributed across all 64-bit outputs.
    EditRNG
    A subclass of StatefulRNG (and thus RNG) that allows customizing many parts of the random number generation.
    Elias
    Contains methods to draw anti-aliased lines based on floating-point coordinates.
    EnumOrderedMap<K extends Enum<?>,​V>
    A simple alternative to EnumMap that has a zero-argument constructor (which makes serialization easier) but is a little less efficient.
    EnumOrderedSet<K extends Enum<?>>
    A simple Set of Enum items (which are already unique if used in a normal Set) that keeps insertion order.
    ExponentialDistribution
    An IDistribution that implements the Exponential distribution.
    FastNoise
    A wide range of noise functions that can all be called from one configurable object.
    FlawedPointHash.CubeHash
    Very similar to FlawedPointHash.QuiltHash, but this doesn't change the pattern in different large squares, and instead repeats a square or cube of symmetric and patterned results over and over (so it can be tiled).
    FlawedPointHash.FNVHash
    FNV32a is OK as a hash for bytes when used in some hash tables, but it has major issues on its low-order bits when used as a point hash (the high bits aren't much better).
    FlawedPointHash.QuiltHash
    Extremely flawed if you're using this as a point hash, but meant to be aesthetically interesting, this produces different symmetrical patterns in squares, as if on a quilt.
    FlawedPointHash.RugHash
    Produces hashes that show strong bias on one axis (usually the later axes matter more) and have nice-looking patterns of dots.
    FlawedRandomness.AddRotate
    A flawed randomness source that adds a rotation of its state, to its state, every generation.
    FlawedRandomness.BigCounter
    A flawed randomness source that depends almost entirely on its starting state for any random-seeming results in its output.
    FoamNoise
    An unusual continuous noise generator that tends to produce organic-looking forms, currently supporting 2D, 3D, 4D and 6D.
    GapShuffler<T>
    Meant to take a fixed-size set of items and produce a shuffled stream of them such that an element is never chosen in quick succession; that is, there should always be a gap between the same item's occurrences.
    GaussianDistribution
    An IDistribution that produces double results with a Gaussian (normal) distribution.
    GearRNG
    A larger-period generator with 127 bits of state (two longs, one is always odd), a period of 2 to the 127, and what should be slightly better speed than the related OrbitRNG.
    GlitchNoise
    A noise generator for 1D, 2D, 3D, 4D, or 6D noise that should look "glitchy", with waves of changing values moving through triangular shapes.
    GoatRNG
    A larger-period generator with 128 bits of state, good speed, and high quality in PractRand testing; it is at least 1-dimensionally equidistributed.
    GoldPointHash
    A relatively simple IPointHash that multiplies each of the x, y, etc.
    GreasedRegion
    Region encoding of on/off information about areas using bitsets; uncompressed (fatty), but fast (greased lightning).
    GWTRNG
    An IRNG implementation that is meant to provide random numbers very quickly when targeting GWT but also to produce the same numbers when used on desktop, Android, or other platforms, and that can have its state read as a StatefulRandomness.
    HashCommon
    Code used internally for hashing OrderedMap, OrderedSet, IntDoubleOrderedMap, Arrangement, and so on.
    HashCommon.EnumHasher  
    Hashers
    Additional implementations of the CrossHash.IHasher interface for more specialized uses, like for use in an OrderedSet or OrderedMap with String keys that should use case-insensitive equality/hashing.
    HastyPointHash
    A group of similar methods for getting hashes of points based on long coordinates in 2, 3, 4, or 6 dimensions and a long for state; like PointHash but faster and maybe not as high-quality.
    IDistribution.SimpleDistribution  
    IndexedDelaunayTriangulator
    Delaunay triangulation.
    IntDoubleOrderedMap
    An int-key and int-value insertion-ordered hash map with with a fast implementation, originally from fastutil as Object2ObjectLinkedOpenHashMap but modified (in OrderedMap) to support constant-time indexed access of keys, values, and entries, and reordering.
    IntIntOrderedMap
    An int-key and int-value insertion-ordered hash map with with a fast implementation, originally from fastutil as Object2ObjectLinkedOpenHashMap but modified (in OrderedMap) to support constant-time indexed access of keys, values, and entries, and reordering.
    IntPointHash
    A group of similar methods for getting hashes of points based on int coordinates in 2, 3, 4, or 6 dimensions and an int for state; the code is similar to HastyPointHash but will be much faster on GWT.
    IntSet
    An unordered set where the items are unboxed ints.
    IntSet.IntSetIterator  
    IntVLA
    A resizable, ordered or unordered variable-length int array.
    IPointHash.IntImpl
    A convenience abstract class to implement IPointHash when you have an int for state.
    IPointHash.LongImpl
    A convenience abstract class to implement IPointHash when you have a long for state.
    IsaacRNG
    This is a port of the public domain Isaac64 (cryptographic) random number generator to Java.
    JitterNoise
    "Classic Perlin" noise with jitter applied to the grid it operates on.
    K2<A,​B>
    An ordered bidirectional map-like data structure, with unique A keys and unique B keys updated together like a map that can be queried by A keys, B keys, or int indices.
    K2V1<A,​B,​Q>
    An ordered multi-directional map-like data structure with two sets of keys and one list of values.
    Lathe32RNG
    A modification of Blackman and Vigna's xoroshiro128+ generator using two 32-bit ints of state instead of two 64-bit longs, as well as modifying the output with two additional operations on the existing state; this is both the fastest generator on GWT I have found without statistical failures, and a StatefulRandomness.
    LFSR
    A Linear Feedback Shift Register that may be used like a StatefulRandomness but is not truly random.
    LightRNG
    This is a SplittableRandom-style generator, meant to have a tiny state that permits storing many different generators with low overhead.
    LinnormRNG
    A mid-high-quality StatefulRandomness that is the second-fastest 64-bit generator in this library that is 1-dimensionally equidistributed across its 64-bit outputs.
    LongPeriodRNG
    An RNG that has a drastically longer period than the other generators in SquidLib, other than IsaacRNG, without sacrificing speed or GWT support.
    LowStorageShuffler
    Gets a sequence of distinct pseudo-random ints (typically used as indices) from 0 to some bound, without storing all of the sequence in memory.
    MaskedShapeGenerator
    Generates procedural shapes based on a mask that determines what values can exist at a location.
    MasonNoise
    Noise functions that delegate work to the best-suited noise type for the requested dimensionality, plus some extra functions that affect a large multi-dimensional area at once.
    MathExtras
    Mathematical operations not provided by java.lang.Math.
    MerlinNoise
    Really strange noise functions that typically produce curving black and white shapes when rendered.
    MersenneTwister
    Mersenne Twister, 64-bit version as a RandomnessSource.
    MiniMover64RNG
    The fastest generator in this library on desktop JVMs; one of Mark Overton's subcycle generators from this article, specifically a CMR with a 64-bit state, that has its result multiplied by a constant.
    MitchellNoise
    An arbitrary-dimensional noise generator; it's not suitable for real-time use, but could be very useful when used with unconventional axes, particularly during level generation.
    MitchellNoise.Vec4  
    MizuchiRNG
    A high-quality StatefulRandomness based on LinnormRNG but modified to allow any odd number as a stream, instead of LinnormRNG's hardcoded stream of 1.
    MoonwalkRNG
    An IRNG implementation that allows the extra functionality of a StatefulRandomness and a SkippingRandomness, as well as allowing reverse-lookup of the state that produced a long using the static MoonwalkRNG.inverseNextLong(long) method, and distance checks between two generated numbers with the static MoonwalkRNG.distance(long, long) method.
    Mover32RNG
    One of Mark Overton's subcycle generators from this article, specifically a cmr^cmr with two 32-bit states; this is the fastest 32-bit generator that still passes statistical tests, plus it's optimized for GWT (sometimes).
    Mover64RNG
    One of Mark Overton's subcycle generators from this article, specifically a cmr^cmr with two 64-bit states.
    NeuralParticle
    Creates a field of particles that tend to form a neuron image type distribution.
    NLFSR
    A Non-Linear Feedback Shift Register that may be used like a StatefulRandomness but is not truly random.
    Noise
    A container class for various interfaces and implementing classes that affect continuous noise, such as that produced by WhirlingNoise or SeededNoise, as well as static utility methods used throughout noise code.
    Noise.Basic1D
    A very simple 1D noise implementation, because a full-blown Perlin or Simplex noise implementation is probably overkill for 1D noise.
    Noise.Exponential1D  
    Noise.Exponential2D  
    Noise.Exponential3D  
    Noise.Exponential4D  
    Noise.Exponential6D  
    Noise.InverseLayered1D  
    Noise.InverseLayered2D  
    Noise.InverseLayered3D  
    Noise.InverseLayered4D  
    Noise.InverseLayered6D  
    Noise.Layered1D  
    Noise.Layered2D  
    Noise.Layered3D  
    Noise.Layered4D  
    Noise.Layered6D  
    Noise.QuilezNoise
    A hybrid between value and gradient noise that may be faster for 1D noise.
    Noise.Ridged2D  
    Noise.Ridged3D  
    Noise.Ridged4D  
    Noise.Ridged6D  
    Noise.Scaled1D  
    Noise.Scaled2D  
    Noise.Scaled3D  
    Noise.Scaled4D  
    Noise.Scaled6D  
    Noise.Slick2D  
    Noise.Slick3D  
    Noise.Slick4D  
    Noise.Slick6D  
    Noise.Sway1D  
    Noise.Sway2D  
    Noise.Turbulent2D  
    Noise.Turbulent3D  
    Noise.Turbulent4D  
    Noise.Turbulent6D  
    Noise.Viny2D  
    Noise.Viny3D  
    Noise.Viny4D  
    Noise.Viny6D  
    NumberTools
    Various numeric functions that are important to performance but need alternate implementations on GWT to obtain it.
    OrbitRNG
    A variant on ThrustAltRNG that gives up some speed to gain a much better period and the ability to produce all possible long values over that period.
    OrderedMap<K,​V>
    A generic insertion-ordered hash map with with a fast implementation, originally from fastutil as Object2ObjectLinkedOpenHashMap but modified to support constant-time indexed access of keys, values, and entries, reordering, and optional hash strategies for unusual keys, such as arrays or usually-dense numeric values.
    OrderedSet<K>
    A generic linked hash set with with a fast implementation, originally from fastutil as ObjectLinkedOpenHashSet but modified to support indexed access of items, reordering, and optional hash strategies for array keys (which fastutil does differently).
    Oriole32RNG
    A modification of Blackman and Vigna's xoroshiro128+ generator using two 32-bit ints of state instead of two 64-bit longs and also incorporating a large-increment counter (Weyl sequence) that is added to the rotated xoroshiro output; this is tied with Lathe32RNG for the fastest generator on GWT I have found that also passes the full 32TB battery of PractRand's statistical tests.
    OrthoLine
    A simple line-drawing algorithm that only takes orthogonal steps; may be useful for LOS in games that use Manhattan distances for measurements.
    PerlinNoise
    Delegates to ClassicNoise methods and always uses the same seed (123456789); that means this produces "Classic Perlin Noise" and not Simplex Noise (both were created by Ken Perlin).
    PermutationGenerator<T>
    Permutation generator for generating all permutations for all sets up to 20 elements in size.
    PermutedRNG
    This is a RandomnessSource in the PCG-Random family.
    PhantomNoise
    Arbitrary-dimensional continuous noise that maintains most of the same style even as the dimensionality gets fairly high.
    PintRNG
    A RandomnessSource based on PCG-Random that has a single int of state.
    PointHash
    A group of similar methods for getting hashes of points based on long coordinates in 2, 3, 4, or 6 dimensions and a long for state.
    PoissonDisk
    This provides a Uniform Poisson Disk Sampling technique that can be used to generate random points that have a uniform minimum distance between each other.
    ProbabilityTable<T>
    A generic method of holding a probability table to determine weighted random outcomes.
    PulleyRNG
    A very-high-quality StatefulRandomness that is meant to be reasonably fast, but also to be robust against frequent state changes, and is built around a strong determine() method.
    RandomBias
    A class that wraps an RNG and allows different String keys to be associated with biases toward low or high results when a method is called that gets a number from the wrapped RNG.
    Region
    NOTE: You should consider GreasedRegion before using this class, unless you know Region does exactly what you want.
    RegionMap<V>
    A small extension of OrderedMap that specifically handles short[] regions as produced by CoordPacker.
    RNG
    A wrapper class for working with random number generators in a more friendly way.
    RNG.CustomRandom
    A subclass of java.util.Random that uses a RandomnessSource supplied by the user instead of the default.
    SeededNoise
    More advanced noise functions, in 2D, 3D, 4D, and 6D, with the last two as options for generating seamlessly-tiling noise using Noise.seamless2D(double[][], long, int, Noise.Noise4D) and/or Noise.seamless3D(double[][][], long, int, Noise.Noise6D).
    ShortVLA
    A resizable, ordered or unordered short variable-length array.
    ShuffledIntSequence
    An infinite sequence of pseudo-random ints (typically used as indices) from 0 to some bound, with all possible ints returned in a shuffled order before re-shuffling for the next result.
    SilkRNG
    An IStatefulRNG implementation that is meant to provide random numbers very quickly when targeting GWT but also to produce the same numbers when used on desktop, Android, or other platforms, and that can have its state read as a StatefulRandomness; it is thus like GWTRNG but should perform better on recent desktop JVMs.
    SobolQRNG
    Implementation of a Sobol sequence as a Quasi-Random Number Generator.
    SpikeDistribution
    An IDistribution that produces results between -1.0 inclusive and 1.0 exclusive, but is much more likely to produce results near 0.0, and does not "round off" like a Gaussian curve around the midpoint.
    SpikeDistribution.SimpleSpikeDistribution
    A variant on SpikeDistribution that has its range shrunk and moved from [-1,1) to [0,1).
    SquidID
    A UUID-like identifier; not compatible with Java's standard UUID but will work on GWT.
    Starfish32RNG
    A modification of Blackman and Vigna's xoroshiro64** generator; uses two 32-bit ints of state like Lathe32RNG but has better equidistribution.
    StatefulRNG
    A slight variant on RNG that always uses a stateful RandomessSource and so can have its state set or retrieved using setState() or getState().
    TangleRNG
    A very fast generator on 64-bit systems that allows choosing any of 2 to the 63 odd-number streams.
    ThrustAltRNG
    A random number generator that is extremely fast but can't return all possible results.
    TimSort<T>
    A stable, adaptive, iterative mergesort that requires far fewer than n lg(n) comparisons when running on partially sorted arrays, while offering performance comparable to a traditional mergesort when run on random arrays.
    TuringPattern
    A technique for producing organic-seeming patterns via iterative processing of random values (reaction-diffusion).
    TweakRNG
    Somewhat experimental RNG that can be configured to smoothly transition between producing mostly values in the center of its range, to producing more values at or near the extremes, as well as favoring high or low results.
    TwistedLine
    Like WobblyLine, this generates orthogonally-connected paths of Coord that meander through an area; unlike WobblyLine, this won't ever generate paths that cross themselves.
    UnorderedMap<K,​V>
    A generic unordered hash map; generally prefer HashMap unless you need array keys.
    UnorderedSet<K>
    A generic unordered hash set with with a fast implementation, based on OrderedSet in this library, which is based on the fastutil library's ObjectLinkedOpenHashSet class; the ordering and indexed access have been removed to potentially reduce the time cost of insertion and removal at the expense of increasing time cost for access by index.
    ValueNoise
    A low-quality continuous noise generator with strong grid artifacts, this is nonetheless useful as a building block.
    VanDerCorputQRNG
    A quasi-random number generator that goes through one of many sub-random sequences found by J.G.
    Voronoi
    A Java implementation of both a 2D Delaunay triangulation algorithm and a Voronoi polygon data structure.
    Voronoi.Edge  
    Voronoi.Polygon  
    Voronoi.Triangle  
    WeightedTable
    A different approach to the same task ProbabilityTable solves, though this only looks up an appropriate index instead of also storing items it can choose; allows positive doubles for weights but does not allow nested tables for simplicity.
    WhirlingNoise
    A Noise class that's here for compatibility; it extends SeededNoise and delegates to it for all methods except WhirlingNoise.noiseAlt(double, double) and WhirlingNoise.noiseAlt(double, double, double).
    WhiteNoise
    Performance-oriented white noise generator for 1D, 2D, 3D, 4D, and 6D.
    WobblyLine
    A drunkard's-walk-like algorithm for line-drawing "wobbly" paths.
    XoRoRNG
    A port of Blackman and Vigna's xoroshiro128+ generator; should be very fast and produce medium-quality output.
    XoshiroStarPhi32RNG
    A modification of Blackman and Vigna's xoshiro128 generator with a different "scrambler" than the default; this generator has four 32-bit states and passes at least 32TB of PractRand (with one "unusual" anomaly at 4TB).
  • Enum Summary 
    Enum Description
    AStarSearch.SearchType
    The type of heuristic to use.