[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Building objects on the fly
From: |
Jae Chan Oh |
Subject: |
Re: Building objects on the fly |
Date: |
Tue, 11 Mar 1997 12:52:01 -0500 (EST) |
> I'm going to point out small things that might be relevant in the
> pseudocode. Don't take these comments as criticism of your method,
> which I think is OK.
>
Glen, your help is always aprreciated and I would need someone to discuss
about SWARM since I am still learning about the system.
Here is some follow ups and questions. (What else? :-))
> > -mateWith: (id) person // person is ptr to the person I want to mate
> with
> > {
> > Person * child;
> >
> > // some stuff deleted
> >
> > // OK, NOW generate a offspring
> > child = [self createChild];
> >
> > [[child getPersonDNA] Mate: [self getPersonDNA] And: [person
> getPersonDNA]
> > withMutation: MUTATION_RATE];
> > return self;
> > }
>
> It's interesting that you instantiate the child THEN setup it's
> genome. I would think this would more properly be done during
> the creation process of the child (i.e. between the createBegin
> and createEnd for the child).
Opps! You helped me find a bug!
I setup the child's genome in createChild randomly, then I try to
allocate yet another dna by calling Mate. I have to call
digital exterminator :-)
>
> > -(id) createChild
> > {
> > Person * child;
> > child = [Person createBegin: [self getZone]];
> >
> > ..... setup some stufF
> >
> > [child setPerson: id]; // create dna, set-up something...
>
> I don't understand what this one means, unless you're using "id"
> as a placeholder.... This has to be pseudocode.
Yes, this is typo. I don't pass a string or an id to setPerson anymore.
I pass just an integer iD. So iD is an integer. -- a bad choice for
an integer type name right? I was not happy with the name either. :-)
>
> > // tell the child where she is
> > [child setWorld: pplPresent World: world ReaperQ: reaperQueue];
>
> The setWorld:World:ReaperQ: method might better be named something
> like setWorld:Space:ReaperQ:. Repeating the word "World" kinda
> makes it look like you're setting the world twice or you have
> two kinds of world, or something.
I will change it. I was looking for another name for world and couldn't
come up with one.
>
> In the original hello-world, the "world" actually was the list
> of the people at the party. The "room" was the space they were
> walking around in. And the "party" was the Swarm of which they
> were a part. This isn't a great way of doing it, and, again, you
> should back off and re-examine how you want to divide your world.
Yes, I also have notice it. I changed the "world" in more like the
one in heatbugs. I don't have "party" anymore or "door".
I have a 2d world -- I wrote a new 2d space class that combines functionality
of 2dToroid and DblBuffer. It seem to work. I will be happy to
contribute it when all testing is over -- and a"pplList".
>
> > numOfFriends = 0; // no friends made so far
> > live = TRUE; // yes, it has just born
> >
> > // create Chromosomes etc
> > dna = [BinChromosome createBegin: [self getZone]];
> > [[dna setLength: (int) (GEN_LENGTH/8)] setRandomInit];
> > dna = [dna createEnd];
> > [self setEvalFuncFromModel];
> >
> > return self;
> > }
> >
> >
> > Do you see anything wrong in the above code?
>
> Except for the comments above, it looks workable! (Don't forget
> to declare "dna". ;-)
>
Here I want to ask a question that always seems to bother me.
Now please consider my interface declaration for Person below.
@interface Person: SwarmObject {
id world; // the world
id pplPresent; // list of Person
id reaperQueue; // for removing
int x, y; // my spatial coordinates
int iD; // iD of the person
int worldXSize, worldYSize; // how big that world is
Color myColor;
// stuff deleted
BinChromosome* dna;
}
Above I declare a ptr to BinChromosome dna within Person.
Now,
I could setup "dna" as in the above*2 (:-)) code. That is directly setting up
dna without using a method:
i.e.
dna = [BinChromosome createBegin: [self getZone]];
[[dna setLength: (int) (GEN_LENGTH/8)] setRandomInit];
but also, I could setup dna by using local variable and by calling a method:
i.e.
tempDNA = [BinChromosome createBegin: [self getZone]];
[[tempDNA setLength: (int) (GEN_LENGTH/8)] setRandomInit];
//now call a method to setup dna
[setDNA tempDNA]
Then in "-setDNA"
-setDNA: (id) _dna {
dna = _dna;
return self
}
So which way is better? Do you recommend any particular method? The dilemma
here is that the dna is a simple type so using an assignment
statement would be enough to set it up. Another example is "-setColor" method.
In one sentance the question is: Do I need to use a method to setup a
simple variable type declared in an object or just using an assignemnt
statement is OK? The only reason to using a method in this case, as far as
I can see, is to let other object to be able to setup the simply type via the
method. Am I right?
One more thing:
My program is currently crashs within objc lib after executing one step
of the simulation and just before executing the next step. Specifically, when
calling objc_msg_lookup at sarray.h.
gdb gves this info.
Program received signal SIGSEGV, Segmentation fault.
0x1b29c4 in objc_msg_lookup (receiver=0x3514c0, op=0x281b04) at sarray.h:216
sarray.h:216: No such file or directory.
(gdb) where
#0 0x1b29c4 in objc_msg_lookup (receiver=0x3514c0, op=0x281b04)
at sarray.h:216
#1 0x6e474 in _i_Activity_c___run_ (self=0x370540, _cmd=0x281af4)
at Activity.m:471
#2 0x1b2fd8 in __objc_init_install_dtable (receiver=0x6e178, op=0x281af4)
at sendmsg.c:245
Which part of the code do you suggest to look up ? Sorry for too much detailed
question but I'm still learning about objective-C and SWARM. If you can give
me any pointers I would aprreiciated it. I can't quite trace the program since
it crashs in between activities which is not part of my code. -- And I'm sure
that it crashs becasue of my code :-)
Thanks again,
-Jae
- Re: problem with raster, (continued)
- 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, 1997/03/10
- 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 <=
- 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
- Re: "zone" or "getZone"? and one additiona question., Jae Chan Oh, 1997/03/14
- Re: "zone" or "getZone"? and one additiona question., glen e. p. ropella, 1997/03/14
- "zone" or "getZone"? and one additiona question., glen e. p. ropella, 1997/03/14