swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Q] Swarm tutorial, random number generator


From: Paul E. Johnson
Subject: RE: [Q] Swarm tutorial, random number generator
Date: Mon, 06 Apr 1998 09:54:35 -0500 (CDT)

On 06-Apr-98 Norberto Eiji Nawa wrote:
> Hello everybody,
> 
> I am now following the tutorial written by Chris Langton and available
> in Benedikt Stefansson's home page in order to get used to the spirit
> of the Swarm package.
> 
> One thing that caught my attention is that when running the example
> simpleObjCBug2, the bug always finds food in the same places and
> following the same path.
Every run looks the same because the random number generator starts with
the same "seed" every time.  This is a good feature so you can design/debug
a simulation.  If you need different random numbers every time, it can
be done by adding some commands. If you get serious about it, you can
look in Sven T's documentation for the random number stuff in swarm.

 I'm working on a section of the FAQ
on"howto" do various little things and if want I can let you see it.
In fact, if you are an absolutely new user, I wish you'd keep a little
journal of the questions or puzzling things you it and share it with
me, so I can better understand the problems that come up.

To save you some trouble, here is a snippit from that FAQ fragment.

-----------------------------------------------------------------------
78. How do I: Use Random Number Generators:

From: Rick Riolo <address@hidden>

 Here is how I start RNGs:
   I have a run-time (or init file or GUI) settable
   parameter, unsigned long seed, and then in a startRNG method
   I do this:

-(void) startRNG {
    char    seedBuff[32];
    if ( seed == 0 ) {
        seed = getpid()*time(0);
        sprintf(seedBuff,"%u",seed);
        [self setParameterName: "seed" ToValue: seedBuff];
    }
    randomGeneratorR = [PMMLCG1 create: globalZone
                 setStateFromSeed: seed];
    uniformUR = [UniformUnsigned create: globalZone
                    setGenerator: randomGeneratorR];
    //... and so on for any other distributions I want.
}




 The distribution of food in the 2D grid
> should be random and the bug should perform random walks, so I guess
> there is something weird happening in the interaction of the random
> number generator libraries and the machine I am using.
> 
> I am running the examples in a SunOS 4.1.3_U1 2 machine. I could not
> find the include files for the family of functions drand48 here, but
> as far as I could see, the Swarm random number generator libs do not
> use any external function.
> 
> Any help will be greatly appreciated. Thanks in advance.
> 
> Eiji
> 
> --
> Norberto EIJI Nawa - Intern student
> Evolutionary Systems Department (Dept.6)
> ATR Human Information Processing Research Labs
> email: address@hidden       http://www.hip.atr.co.jp/~xnawa/
>  
> 
>                   ==================================
>    Swarm-Support is for discussion of the technical details of the day
>    to day usage of Swarm.  For list administration needs (esp.
>    [un]subscribing), please send a message to <address@hidden>
>    with "help" in the body of the message.
>                   ==================================

----------------------------------
E-Mail: Paul E. Johnson <address@hidden>
Date: 06-Apr-98
Time: 09:49:48

This message was sent by XFMail
----------------------------------

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.
                  ==================================


reply via email to

[Prev in Thread] Current Thread [Next in Thread]