swarm-support
[Top][All Lists]
Advanced

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

Re: question about copying agents


From: Rick Riolo
Subject: Re: question about copying agents
Date: Tue, 13 Apr 1999 15:30:41 -0400 (EDT)

Paul,
I'm not sure what roger had in mind, but I think
part of the issue is seen is this example:

What would happen if
each Heatbug had a pointer to some other object
that contained state of the bug, eg, a pointer
to an Array object that had entries for preferences
on different dimensions, say.
Then the copyIVars would just copy the pointer
to that array, and all your bugs would be
sharing the same Array of values, whereas probably
you want each to have its own Array of values.

- r

Rick Riolo                           address@hidden
Program for Study of Complex Systems (PSCS)
4477 Randall Lab                
University of Michigan         Ann Arbor MI 48109-1120
Phone: 734 763 3323                  Fax: 734 763 9267
http://www.pscs.umich.edu/PEOPLE/rlr-home.html

On Tue, 13 Apr 1999, Paul E. Johnson wrote:

> Date: Tue, 13 Apr 1999 14:17:45 -0500
> From: Paul E. Johnson <address@hidden>
> To: swarm <address@hidden>
> Subject: question about copying agents
> 
> 
> I got to reviewing some old swarm mail and I came again to the question
> of how agents can be copied.  I found a note by Roger saying that,if you
> only need to create a "shallow" copy, you can do so by copyIVars.  He
> has a recommendation like this:
> 
>  Right now, if you want a
> Swarm-style copy: message, all you have to do is the copy the following
> method into your class:
> 
> - copy: aZone
> {
> return [aZone copyIVars: self];
> }
> (http://www.santafe.edu/projects/swarm/archive/list-archive.9702/0053.html)
> 
> What does "shallow" mean, as opposed to "deep"?
> 
> Here is what I really want to know, I guess:  
> 
> Is it correct that the copyIVars method will create a new memory
> allocation and the new thing created will exist "as if" it had all the
> createBegin/createEnd stuff done to it that was done to the original? 
> In heatbugs, suppose you look at the heatbugModelSwarm.  Could you just
> create one heatbug, call it "aHeatbug" and then clone it over and over
> with repeated calls like:
>    for(i=0;i<N;i++)
> {
>    [newHeatbug=[self copyIVars: aHeatbug ];
>    [heatbugList addLast: newHeatbug];
> }
> (I think this works because heatbugModelSwarm is a Zone, right?).
> 
> Does this give you a list of bugs, all of whom are interchangable with
> the original?
> 
> What "deep" stuff does not get copied over?
> 
> In particular, if you created a subclass from Heatbug and called it
> Coolbug, and then added some instance variables, would the copyIVars
> applied to Coolbug catch all the variables of Coolbug, including the
> ones it inherits from the superclass? I have the fear that the "shallow"
> versus "deep" distinction means copyIVars might not pick up all of the
> inherited instance variables.
> 
> -- 
> Paul E. Johnson                       email: address@hidden
> Dept. of Political Science            http://lark.cc.ukans.edu/~pauljohn
> University of Kansas                  Office: (785) 864-9086
> Lawrence, Kansas 66045                FAX: (785) 864-5700
> 
>                   ==================================
>    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.
> 
> 

                  ==================================
   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]