Hi when ever i use random dont really get the random numbers i need. for example i am trying to simulate a dice roll with this function:
1 2 3 4 5 6 7
int DiceRoll(){
srand(time(0));
return rand() % 6 + 1;
}
and this does return a randon number. However this is how i am calling the function:
1 2 3
int attack = DiceRoll();
int def = DiceRoll();
whenever i call this the numbers are always equal. I understand this is because i am using the time seed, and not enough time has passed for a new number to be calculated. Want would be a better seed for srand()? I have not done munch coding using random numbers before.