#include "rng.h"

RNG::RNG(): init_seed(time(0)), curr_rand_num(0) {
        srand(init_seed);
}

RNG::RNG(const unsigned int seed): init_seed(seed), curr_rand_num(0) {
        srand(init_seed);
}

int RNG::rand_num() {
        return curr_rand_num = rand();
}

int RNG::rand_between(const int lower_bound, const int upper_bound) {
        curr_rand_num = rand();

        return lower_bound + (curr_rand_num % (upper_bound - lower_bound));
}

int RNG::rand_under(const int upper_bound) {
        curr_rand_num = rand();

        return curr_rand_num % upper_bound;
}

unsigned int RNG::get_init_seed() const {
        return init_seed;
}

int RNG::get_curr_rand_num() const {
        return curr_rand_num;
}

template<class T> T &RNG::get_rand_in_vector(const std::vector<T> &vec) {
        curr_rand_num = rand();

        return vec[curr_rand_num % vec.size()];
}
