[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Swarm-Support] Also Button Problem
From: |
Paul E Johnson |
Subject: |
Re: [Swarm-Support] Also Button Problem |
Date: |
Thu, 10 Apr 2003 11:13:54 -0500 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020918 |
Without seeing the code in your ProbeMaker where you set the Grids in
there and then design a method for it to hunt through the grids in
response to the makeProbeAtX:Y: method, I can't say what is going wrong.
Could be a typo in your Message line where it gives an extra :.
Anwyay, here's a makeProbeAtX:Y: method from another project I use. This
one is from my MultiGrid2d class, the multiple-occupancy grid that I've
posted in the past here. This one searches through a cell at x,y and
chooses one item at random to probe. You need to redesign your method to
search through the grids to find an agent at x,y.
- makeProbeAtX: (unsigned)x Y: (unsigned)y
{
id obj;
id <AppCell> cell;
if (x >= 0
&& x < xsize
&& y >= 0
&& y < ysize)
{
cell = *discrete2dSiteAt(lattice, offsets, x, y);
if(cell)
{
obj = [cell getRandomItem];
CREATE_PROBE_DISPLAY (obj);
}
else
GUI_BEEP ();
}
else
[WarningMessage
raiseEvent:
"MultiGrid2d: invalid coordinates to make probe (%d,%d)\n",
x, y];
return self;
}
luo pi wrote:
Hi,
With Paul Johnson's advice, I design a class---
ProbeMaker, and write the "makeProbeAtX:Y:" method in
it. In the ObserverSwarm, the source coder is as
follows:
ProbeMaker * probeMaker;
…
probeMaker = [ProbeMaker createBegin: self];
probeMaker = [probeMaker createEnd];
[worldRaster setButton: ButtonRight
Client: probeMaker
Message: M(makeProbe:AtX:Y:)];
However, I find that when clicking with right button
on the raster, the program is closed even if there is
nothing except the sentence “return self;” in
"makeProbeAtX:Y:" method.
I do not know where the problem is. Maybe you can give
me more detailed about this thought.
Thank you very much!
Patrick.L
--
Paul E. Johnson email: address@hidden
Dept. of Political Science http://lark.cc.ku.edu/~pauljohn
1541 Lilac Lane, Rm 504
University of Kansas Office: (785) 864-9086
Lawrence, Kansas 66044-3177 FAX: (785) 864-5700