float point exception, waiting for debugging

This commit is contained in:
2024-06-30 02:51:24 -04:00
parent c5f5f969a4
commit e513e78d1d
32 changed files with 915 additions and 0 deletions

39
src/rng.cc Normal file
View File

@ -0,0 +1,39 @@
#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()];
}