[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Building objects on the fly
From: |
glen e. p. ropella |
Subject: |
Building objects on the fly |
Date: |
Mon, 10 Mar 1997 16:23:16 -0700 |
joh> Do we need to use "buildObjects" whenever creating a new object?
To this question, I give a resounding "No!" Not only is it
unecessary to "build" all the objects in a swarm in a special
"buildObjects" method; but, *I* claim that it can sometimes
be very artificial to do so. (I have no idea if anybody agrees
with me on this, so don't take my word as an expert.)
What you see in demos like heatbugs, mousetraps, etc. are
fairly static models that don't really change much over time.
Hence, a buildObjects makes sense because it tries to isolate
all the object creation code in one spot, which is naturally
the beginning of the run.
However, for a model that will grow, change, and/or disappear,
this may not be a good way to do it. So, feel free to do it
however you want and *don't* follow the examples in our demos
blindly. Step back and think about where things should be
created and how they should be created with respect to whatever
*you* are modelling.
joh> In my simulation, the objects (say Person) are created and
joh> destroyed dynamically -- that means not in the Observer
joh> swarm/Model Swarm but rather Person Swarm objects can create
joh> offsprings. Now, I use +createBegin and -createEnd pair to do
joh> that but I'm getting a core dump on message to an object defined
joh> in swarm library. Looks like I have set up the
joh> "on-the-fly-created" object incorrect. Do I need to call
joh> buildObject and do +createBegin and -createEnd pair inside of
joh> buildObject? If so then what if I need to create different
joh> object types depending on the situation within one class? -- I
joh> can have only one buildObject right?
Now, with regard to you're current problem.... I'm not sure I understand
what you mean by calling "buildObject and do +createBegin and
-createEnd ...". I assume the "buildObjects" method you're
referring to is a message on the ModelSwarm. Right? If so, then
you certainly don't want to send that message to the modelSwarm everytime
you want to create some lowly little bug. The way that message was
used in the demos is as an initialization message. It should probably
be called initializeModelObjects or createModelObjects or something.
Any individual creation/death you want to do *inside* any given
model should be done on an individual basis. For example, if you
have a list of people being born and dying, you might have the Person
doing the birthing initiate a birthing process by scheduling
a message to itself saying
[myModelSchedule at: getCurrentTime() +1 createActionTo: self
message M(giveBirthWithGenome:) : (id)genome];
Then in the Person class, you might have the method:
-(id) giveBirthWithGenome: (id) genome {
id newPerson;
[ ... blahblahblah ...]
newPerson = [Person createBegin: myParentSwarm];
[newPerson setUpAllAttributes];
newPerson = [newPerson createEnd];
[ ... blahblahblah ...]
return newPerson;
}
Now, there should be some message that the modelSwarm can
accept to tell it to add the new person to the appropriate
lists and the space and such. But, the creation of the
individuals should be abstracted from the system you're trying
to model.
Did hit the board? Or did I misunderstand?
glen
- problem with raster, Kevin Crowston, 1997/03/06
- Re: problem with raster, Kevin Crowston, 1997/03/06
- Re: problem with Raster, Sven Thommesen, 1997/03/06
- Re: problem with Raster, mcmullin, 1997/03/10
- Re: problem with Raster, Jae Chan Oh, 1997/03/10
- Building objects on the fly,
glen e. p. ropella <=
- Re: Building objects on the fly, Jae Chan Oh, 1997/03/10
- Re: Building objects on the fly, glen e. p. ropella, 1997/03/11
- Re: Building objects on the fly, Jae Chan Oh, 1997/03/11
- Re: Building objects on the fly, glen e. p. ropella, 1997/03/11
- "zone" or "getZone"? and one additiona question., Jae Chan Oh, 1997/03/13
- Classifier systems, Tony Bigbee, 1997/03/13
- Maintaining a Debian Swarm package, Thor Sigvaldason, 1997/03/14
- Re: Maintaining a Debian Swarm package, Karl Sackett, 1997/03/14
- Re: Classifier systems, Rick Riolo, 1997/03/14
- "zone" or "getZone"? and one additiona question., J.J. Merelo Guervos, 1997/03/14