I'm struggling to get random numbers, in the below code, If I take out the time seed, I get different random numbers each roll, however they are the same on each play through.
If I leave the time seed in, the rolls are always 1 and 1. Please can someone advise what I am doing wrong? I've tried making the game sleep a few seconds to change the results of time time seed call
void dicegame::battle(character *a, character *b)
{
int rollone = this->roll(); int rolltwo = this->roll(); int total1 = rollone+rolltwo; Sleep(5000);
int rollone2 = this->roll(); int rolltwo2 = this->roll(); int total2 = rollone2+rolltwo2; Sleep(5000);
}
int dicegame::roll()
{
static std::uniform_int_distribution<int> u(1, 6);
static std::default_random_engine e;
e.seed(time(0));
int roll = (u(e));
return roll;
}