ilpincy / argos3-kilobot

Kilobot plugin for the multi-robot ARGoS3 simulator
15 stars 14 forks source link

Rand_hard() returns the same random number for all kiblots #1

Closed eliseofe closed 8 years ago

eliseofe commented 8 years ago

Easy to reproduce, enough to print the random numbers generated in the sync example.

It may be due to the fork() in the common interface cpp controller that forks also the seed variable, which then is used by all processes

ilpincy commented 8 years ago

The current implementation of rand_hard() calls rand_soft(). Since the seed for rand_soft() is initialized to 0xAA to reproduce the behavior of the real Kilobot, you get the same numbers for rand_hard().

The solution should be for rand_hard() to get a dedicated implementation, maybe a Mersenne-Twister.

To work around this issue for the time being, it's enough to set a new random seed in the Kilobot script with rand_seed().