io.github.srs.utils.random

Members list

Type members

Classlikes

trait RNG

A trait representing a Random Number Generator (RNG).

A trait representing a Random Number Generator (RNG).

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
class SimpleRNG
object Rand

A companion object for the Rand type, providing utility methods for working with random values.

A companion object for the Rand type, providing utility methods for working with random values.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Rand.type
object RandomDSL

A domain-specific language (DSL) for generating random values using a Rand type.

A domain-specific language (DSL) for generating random values using a Rand type.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
RandomDSL.type
final case class SimpleRNG(seed: Long) extends RNG

A simple implementation of the RNG trait using Scala's built-in Random class. This RNG generates random values based on a seed.

A simple implementation of the RNG trait using Scala's built-in Random class. This RNG generates random values based on a seed.

Value parameters

seed

the initial seed for the random number generator.

Attributes

Note

This RNG is deterministic, meaning it will produce the same sequence of random values for the same seed.

Supertypes
trait Serializable
trait Product
trait Equals
trait RNG
class Object
trait Matchable
class Any
Show all

Types

type Rand[+A] = RNG => (A, RNG)

A domain-specific alias for a function that generates a random value of type A and returns it along with the next state of the RNG.

A domain-specific alias for a function that generates a random value of type A and returns it along with the next state of the RNG.

Attributes

Extensions

Extensions

extension [A](ra: () => A)
def flatMap[B](f: A => () => B): () => B

Flat-maps the value generated by the Rand to a new Rand of type B using the provided function f.

Flat-maps the value generated by the Rand to a new Rand of type B using the provided function f.

Type parameters

B

the type of the value to be generated by the transformed Rand.

Value parameters

f

the function to transform the value of type A into a new Rand of type B.

Attributes

Returns

a new Rand that generates a value of type B.

def map[B](f: A => B): () => B

Maps the value generated by the Rand to a new value of type B using the provided function f.

Maps the value generated by the Rand to a new value of type B using the provided function f.

Type parameters

B

the type of the value to be generated by the transformed Rand.

Value parameters

f

the function to transform the value of type A into a value of type B.

Attributes

Returns

a new Rand that generates a value of type B.