/**
 * @file
 * @brief General purpose pseudo-random number generator for CEX.
 */
#pragma once
#include "cex.h"

typedef struct Random_c
{
    u64 state[2]; // Random generator internal state
    u64 n_ticks;  // number of any Random() generator calls after last Random.seed()
} Random_c;

struct __cex_namespace__Random {
    // Autogenerated by CEX
    // clang-format off

    /// Fill buffer with randomized data
    void            (*buf)(Random_c* self, void* buf, usize buf_len);
    /// Random floating point number in [0;1.0] range
    f32             (*f32)(Random_c* self);
    /// Random i32 number in [min; max] range
    i32             (*i32)(Random_c* self, i32 min, i32 max);
    /// Next random u32 number
    u32             (*next)(Random_c* self);
    /// Random probability simulation (rolling a dice)
    bool            (*prob)(Random_c* self, f32 prob_threshold);
    /// Returning random range in [min; max). Useful for arrays.
    usize           (*range)(Random_c* self, usize min, usize max);
    /// Resets seed of random generator (must be called before first use)
    void            (*seed)(Random_c* self, u64 seed);

    // clang-format on
};
CEX_NAMESPACE struct __cex_namespace__Random Random;

