Random Generator

Requests regarding how to set up experiments in ARGoS.
Max
Posts: 20
Joined: Tue Mar 31, 2015 4:55 pm

Random Generator

Postby Max » Tue Apr 28, 2015 4:45 pm

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

pincy
Site Admin
Posts: 632
Joined: Thu Mar 08, 2012 8:04 pm
Location: Boston, MA
Contact:

Re: Random Generator

Postby pincy » Tue Apr 28, 2015 8:40 pm

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
I made ARGoS.

Max
Posts: 20
Joined: Tue Mar 31, 2015 4:55 pm

Re: Random Generator

Postby Max » Wed Apr 29, 2015 5:09 pm

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

pincy
Site Admin
Posts: 632
Joined: Thu Mar 08, 2012 8:04 pm
Location: Boston, MA
Contact:

Re: Random Generator

Postby pincy » Wed Apr 29, 2015 5:33 pm

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
I made ARGoS.

Max
Posts: 20
Joined: Tue Mar 31, 2015 4:55 pm

Re: Random Generator

Postby Max » Tue May 05, 2015 2:45 pm

Noted Carlos,

Thank you very much.


Return to “How to... ?”