Skip to content

Engine → Core → random.h

random::random_engine

Syntax

class CONJURE_API random_engine

Constructors

AccessSignatureDescription
publicrandom_engine();
publicexplicit random_engine( u64 seedValue);
publicrandom_engine( const random_engine &) = default;
publicrandom_engine( random_engine &&) noexcept = default;

Destructors

AccessSignatureDescription
public~random_engine();

Variables

AccessNameTypeDefaultDescription
privatemEngineengineengine(DEFAULT_SEED)
privatemSeedu64DEFAULT_SEED

Functions

Public

chance

[[nodiscard]] bool chance(
    f64 probability);

True with the given probability.

current_seed

[[nodiscard]] u64 current_seed() const noexcept;

The seed the current sequence started from.

discard

void discard(
    u64 count) noexcept;

Advances the sequence by the given number of draws without producing values.

max

[[nodiscard]] static constexpr result_type max() noexcept;

Largest value operator() can return, as required by std::uniform_random_bit_generator.

min

[[nodiscard]] static constexpr result_type min() noexcept;

Smallest value operator() can return, as required by std::uniform_random_bit_generator.

raw

[[nodiscard]] engine &raw() noexcept;

The wrapped engine, for callers that need the standard interface directly.

seed

void seed(
    u64 seedValue) noexcept;

Restarts the sequence from the given seed.

uniform

template <typename T> [[nodiscard]] T uniform(
    T minimum,
    T maximum);

Uniform integer in [min, max] or floating point value in [min, max).

unit_vector3

template <typename Vector3 = std::array<f32, 3>> [[nodiscard]] Vector3 unit_vector3();

A uniformly distributed point on the unit sphere. Two engine draws; x and y may differ in the last bit between platforms (see the free random::unit_vector3).

Operator Overloads

Public

operator()

[[nodiscard]] result_type operator()() noexcept;

The next raw 64-bit output.

operator=

random_engine &operator=(
    const random_engine &) = default;
random_engine &operator=(
    random_engine &&) noexcept = default;

operator==

[[nodiscard]] bool operator==(
    const random_engine &other) const noexcept;

True when both engines are in the same state and will produce the same sequence.