Page 1 of 1

Random Generator

Posted: Tue Apr 28, 2015 4:45 pm
by Max
Hi,

Based on the foraging.argos we are able to randomly generate food items in a area with a pre-determined location using the following codes:

m_pcRNG = CRandom::CreateRNG("argos");
for(UInt32 i = 0; i < unFoodItems; ++i) {
m_cFoodPos.push_back(
CVector2(m_pcRNG->Uniform(m_cForagingArenaSideX),
m_pcRNG->Uniform(m_cForagingArenaSideY)));

i will like to ask if is possible for us to generate a random location for the area where the food was generated in using the random generators functions provided.

Thank you

Cheers,
Max

Re: Random Generator

Posted: Tue Apr 28, 2015 8:40 pm
by pincy
Hi Max,
i will like to ask if is possible for us to generate a random location for the area where the food was generated in using the random generators functions provided.
here by 'location' you mean the rectangular area delimited by m_cForagingArenaSideX and m_cForagingArenaSideY?

If that is the case, one way to do it is moving that rectangular area around in a random fashion.

IDEA: Represent the rectangular area as a center (cx,cy) and a side length (sx,sy) like so:

Code: Select all

struct SArea { CVector2 Center; CVector2 Side; };
Then, define a range for the center and the side, and use m_pcRNG->Uniform to pick a center and a side length. Obviously, you need to make sure that the extent of SArea does not exceed the arena limits.

Cheers,
Carlo

Re: Random Generator

Posted: Wed Apr 29, 2015 5:09 pm
by Max
Hi Carlo,

Thank you for your reply and idea. even though by using the idea representing the rectangular area as a center (cx,cy) and a side length (sx,sy), i observe that the random pattern generated by m_pcRNG->Uniform are predictable and will appear at the same randomize location when reset.

Is it possible to make this randomizing unpredictable?

Thank you
Cheers
Max

Re: Random Generator

Posted: Wed Apr 29, 2015 5:33 pm
by pincy
Hi Max,

In the .argos file of an experiment, the attribute "random_seed" of the <experiment> tag sets the random seed of the random number generator. Once the seed is set, the sequence of random numbers is always the same. This is to ensure that experiments in ARGoS are repeatable - this way you can find and fix bugs in your code.

If you want to have a different random seed for each time you press the reset button, you just need to set the random seed to zero in the .argos file:

Code: Select all

<?xml version="1.0" ?> <argos-configuration> <framework> <experiment ... random_seed="0" /> ... </framework> ... </argos-configuration>
or delete the attribute from the <experiment> tag altogether.

Cheers,
Carlo

Re: Random Generator

Posted: Tue May 05, 2015 2:45 pm
by Max
Noted Carlos,

Thank you very much.