Subject: RE: walk towards a target
From: Hengeveld, Geerten (Geerten.Hengeveld@wur.nl)
Date: Fri Apr 07 2006 - 13:58:12 CEST
Hi Mira,
I'm not a Cormas or Smalltalk pro, but during the course in cormas last month I encountered the same problem while trying to modify the Fire model.
the 'wayTo' sollution did not seem to work because some cells were not allowed, so I came up with the following procedure: it assumes that the destination is an instance variable, just as perceptionrange, but it could easily be rewritten to take the destination as an argument and to only evaluate the envirnment defined neighbouring cells.
hope this is of any help
Geerten Hengeveld
Resource Ecology Group
Wageningen University
www.reg.wur.nl
moveTowardsDestination
|dest dist1 dist2 neighs|
dest:= self patch neighbourE.
dest = nil ifTrue: [dest:= self patch neighbourW]."to correct for the neighbour being the border"
dist1:= dest distCell: self destination.
neighs := self perception: self perceptionRange."all the cells within the perception"
neighs
do: [:x|
dist2:=x distCell: self destination.
dist1 > dist2
ifTrue: [ dist1:=dist2.
dest:= x]
]."choose the cell closest to the destination"
self leave.
self moveTo: dest.
-----Oorspronkelijk bericht-----
Van: owner-cormas@cirad.cirad.fr namens Miao Wang
Verzonden: di 4-4-2006 0:32
Aan: cormas@cirad.fr
CC:
Onderwerp: walk towards a target
Hello!
I am trying to let the agents in my model to walk towards some targets.I think maybe the method: walkToMaxOf: aSymbol constrainedBy: aBlock is the right method.I don't know What 'aSymbol' refers to? is 'aSymbol' an instance variable of spatial entity or a instance variable of agents? what is the meaning of 'ex-aequo destinations'in the notation for this method?
Great Thanks!
Mira
Miao Wang at Geomatics
School of Civil Engineering and Geosciences
G.19, Cassie Building,
University of Newcastle Upon Tyne, NE1 7RU
England
Email: miao.wang1@ncl.ac.uk