Class SolaRandom

java.lang.Object
technology.sola.engine.utils.SolaRandom

@NullMarked public class SolaRandom extends Object
Wrapper around Random that exposes some additional convenience methods. This wrapper will ensure that random number generation will work across different SolaPlatforms.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
     
    static float
     
    static float
    nextFloat(float min, float max)
    Returns a pseudorandom, uniformly distributed float value between min (inclusive) and max value (inclusive)
    static int
    nextInt(int bound)
    Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive)
    static int
    nextInt(int min, int max)
    Returns a pseudorandom, uniformly distributed int value between min (inclusive) and max value (inclusive)
    static void
    setSeed(long seed)
    Sets the seed for random number generation.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • setSeed

      public static void setSeed(long seed)
      Sets the seed for random number generation.
      Parameters:
      seed - the seed
    • nextBoolean

      public static boolean nextBoolean()
      Returns:
      the next pseudorandom, uniformly distributed boolean value
    • nextInt

      public static int nextInt(int bound)
      Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive)
      Parameters:
      bound - the exclusive boundary value
      Returns:
      the random int value
    • nextInt

      public static int nextInt(int min, int max)
      Returns a pseudorandom, uniformly distributed int value between min (inclusive) and max value (inclusive)
      Parameters:
      min - the inclusive min value
      max - the inclusive max value
      Returns:
      the random int value
    • nextFloat

      public static float nextFloat()
      Returns:
      the next pseudorandom, uniformly distributed float value between 0.0 and 1.
    • nextFloat

      public static float nextFloat(float min, float max)
      Returns a pseudorandom, uniformly distributed float value between min (inclusive) and max value (inclusive)
      Parameters:
      min - the inclusive min value
      max - the inclusive max value
      Returns:
      the random float value