#include "random.h"

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;
}

uint32_t random_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;
}

uint32_t random_u32_range(Random_Generator *random_generator, uint32_t min, uint32_t max) {
    return min + (random_u32(random_generator) % (max - min + 1));
}