Vitus
Resource contributor
- Messages
- 1,480
- Country

Hi there,
I want to implement a radomize function to determine the weight of the passengers for my load manager. I tried to use the rand() function, but it seems like this doesn't work. What I tried is something like this:
the seeding value fs_time in this case is synchronized to the
token variable before calling the updatePayload function.
I also tried to use a C++ time variable but that didn't work either, the result is always the same: the weight is set to a "random" number once, but when constantly updated, the number does only change after about a minute - then it is increased by exactly +1.
Do you have any idea how to get a real pseudo-random number?
Regards
Vitus
I want to implement a radomize function to determine the weight of the passengers for my load manager. I tried to use the rand() function, but it seems like this doesn't work. What I tried is something like this:
Code:
FLOAT64 grd_pax_weight1 = 0.0;
void updatePayload()
{
HRESULT hr;
srand( (int) fs_time );
grd_pax_weight1 = (((FLOAT64) rand() / 200 ) + 100);
}
the seeding value fs_time in this case is synchronized to the
Code:
E:LOCAL TIME,second
I also tried to use a C++ time variable but that didn't work either, the result is always the same: the weight is set to a "random" number once, but when constantly updated, the number does only change after about a minute - then it is increased by exactly +1.
Do you have any idea how to get a real pseudo-random number?
Regards
Vitus
