[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Questions on probes and inheritance
From: |
David Aliaga |
Subject: |
Questions on probes and inheritance |
Date: |
Fri, 13 Oct 2000 04:21:01 -0700 (PDT) |
Hello Swarm Community:
Let me put some questions: (in order of importance)
1) I have a ZoomRaster and an Object2dDisplay. Here we
can see a bunch of agents of class "Predator" and
"Prey". Since they have some things in common I
reorganized the simulation and made them subclasses of
a more general class "Bug" (a subclass of SwarmObject)
OK, so now I have the preds and preys moving in the
ZoomRaster. I Stop the simulation and right-click in
one of them to see the internal state. I got a probe
of course. The instance variable of Pred, for example
is
int haveEaten;
So that is what I got.
But there are 2 instance variables of the superclass
"Bug"(inherited by Pred I suppose) which would be
interesting to display too:
int xPos,yPos;
How can I make that the probe displays these
superclass instance variables? (this probe is
generated by right clicking, not by writing code)
(Actually I have click the name of the object, got a
complete Probe, then click the Superclass button...
But there should be a more convenient way...)
2) I have another object called "theWorld" of class
"Mundo2d" subclass of a Grid2d object, that also have
some instance variables I would like to display. I
tried to make a probe:
probeWorld= [EmptyProbeMap createBegin: aZone];
[probeWorld setProbedClass: [Mundo2d class]];
probeWorld = [probeMap createEnd];
[probeWorld addProbe: [probeLibrary
getProbeForVariable: "number_of_steps"inClass:[Mundo2d
class]]];
[probeLibrary setProbeMap: probeWorld For: [Mundo2d
class]];
But I got the following message:
*** event raised for warning: WarningMessage
*** function: _i_ProbeMap__addProbe_(), file:
/src/Swarm/swarm/src/objectbase/Pr
obeMap.m, line: 508
Probe not added to ProbeMap because Mundo2d is not a
superclass of ModelSwarm
*** execution continuing...
I have to point out that when the object was not a
subclass of Grid2d but of SwarmObject there was no
problem. Also I can get a Probe of the object when I
right-click its name in another probe...
3) One question just out of curiosity:
I notice that in the Template files at the begining
of BuidObjects in TemplateModelSwarm.m there is a
[super BuildObjects]
but in the tutorial examples in the same part this
line doesnt appear. Same happens in BuildActions. Why?
Is it not necessary to call the superclass?
Thanks a lot
David
__________________________________________________
Do You Yahoo!?
Get Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/
==================================
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.
- Questions on probes and inheritance,
David Aliaga <=