#ifndef RANDOM_H
#define RANDOM_H

typedef struct {
    uint32_t seed;
    uint32_t state;
} Random_Generator;

static inline void random_init(Random_Generator *random_generator, uint32_t seed) {
    if(seed == 0) {
        seed = 1;
    }
    random_generator->seed = seed;
    random_generator->state = random_generator->seed;
}

static inline uint32_t random_next_u32(Random_Generator *random_generator) {
    uint32_t x = random_generator->state;
    
    x ^= x << 13;
    x ^= x >> 17;
    x ^= x << 5;

    random_generator->state = x;

    return x;
}

static inline uint32_t random_u64_range(Random_Generator *random_generator, uint32_t min, uint32_t max) {
    return min + (random_next_u32(rng) % (max - min + 1));
}


#endif