Subject: RE: bug - perceiving neighbourhood
From: Nicolas Becu (becu@uni-hohenheim.de)
Date: Wed May 11 2005 - 12:44:17 CEST
In the same range of idea (about perceiving neighbourhood), here is a method
to identify the nearest cell verifying a condition
The method is to be added in the SpatialEntityElement class or in the "Cell"
class of your model.
nearestCellVerifying: aBlock1
| collec minimum d target |
collec := (self spaceModel spatialEntities at: self class name)
select: [:c | aBlock1 value:
c].
minimum := 100000.
collec do: [:c | c ~= self
ifTrue:
[d := self distCell: c.
d < minimum
ifTrue:
[minimum := d.
target := c]]].
^target
The method could be added to a future version of Cormas.
Cheers
Nicolas
_____
From: owner-cormas@cirad.cirad.fr [mailto:owner-cormas@cirad.cirad.fr] On
Behalf Of Sk. Morshed Anwar
Sent: 10 May 2005 20:07
To: Cormas
Subject: bug
Dear members,
I need to some suggestions.
I need to calculate the shortest distance between two points (lets say, x
and y) in the model space (cell). the agents will calculate the distance and
head towards the direction. so, another point is to decide the direction.
unlike the Fireman agents, in the Fire model of the user guide, the agents
dont walk randomly. they perceive one object in the environment and find the
shortest distance and direction to take. then move. any idea?
i wanted to implement the method: moveAndTrackTo: aPatch
moveAndTrackTo: aPatch
"Move to aPatch and display a line from origin center to aPatch center"
| origin gc |
aPatch isNil ifTrue: [self halt].
origin := self patch copy.
self moveTo: aPatch.
gc := self patch view graphicsContext.
gc paint: (ColorValue perform: #red).
gc displayLineFrom: origin center to: aPatch center
in the debugger, i see my agent has its patch and the above method copy its
patch. but later the variable origin shows nil. so center can not pass any
message to nil receiver. i dont know where is the problem. any help?
BTW, i am using cormas 2004 January 20, 2005 version with VW7.3nc platform.
morshed
i got the following bug says, "unhandled exception: message not understood
#center"
doesNotUnderstand: aMessage
"The default behavior is to create a Notifier containing the
appropriate message and to allow the user to open a Debugger.
Subclasses can override this message in order to modify this behavior."
| excpt resumeValue |
excpt := Object messageNotUnderstoodSignal newException.
excpt
searchFrom: thisContext;
parameter: aMessage;
messageText: [| selectorString |
selectorString :=
[aMessage selector printString]
on: Error
do: [:ex |
ex return:
(#errSelectorNotPrintable << #dialogs >> '** unprintable selector
**')
expandMacros asString].
(#errNotUnderstood << #dialogs >> 'Message not understood: <1s>')
expandMacrosWith: selectorString];
originator: self;
makeSureResumable.
resumeValue := excpt raiseSignal.
^excpt reachedDefaultHandler
ifTrue: [self perform: aMessage selector withArguments: aMessage
arguments]
ifFalse: [resumeValue]
"3 zork."
_____
Do you Yahoo!?
Yahoo! Mail - Find what you need with new enhanced search. Learn
<http://us.rd.yahoo.com/evt=29917/*http:/info.mail.yahoo.com/mail_250>
more.