Subject: RE: Comment limiter le déplacement d'un agent autour d'un objet fixe?
From: Hengeveld, Geerten (Geerten.Hengeveld@wur.nl)
Date: Wed May 31 2006 - 09:34:49 CEST
Hi Abdou Fati,
My french is not that good, but as far as I understood, you want an agent to move towards another agent. I also had problems with the movetowards method. Apparently it needs some similar cells to create a path.
I have posted the method below earlier, but I think that it might help you out aswell.
it assumes an agent variable destination, that contains the cell that the agent wants to move towards (in your case the cell where a water point is located) then it checks the neighbours for their distnance to the destination cell. consequently the agent moves to the cell that is closest to the destination.
I hope this helps
Geerten Hengeveld
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.
(the method was writen for the firemen model that is part of the tutorial, so any loose ends should connect there)
_____
From: owner-cormas@cirad.cirad.fr [mailto:owner-cormas@cirad.cirad.fr] On Behalf Of Fadimata Abdou
Sent: woensdag 31 mei 2006 0:02
To: cormas@cirad.fr
Subject: Comment limiter le déplacement d'un agent autour d'un objet fixe?
Bonjour,
J'aimerai que l'agent berger tourne autour du point d'eau c'est-à-dire qu'il ne s'éloigne pas beaucoup du point d'eau. Le point d'eau est une entité Objet du modèle qui est fixe et le berger bouge avec son troupeau d'une cellule à l'autre.
J'ai essayer d'utiliser la méthode moveTowards: mais ça ne marche pas car je pense que je ne l'utilise pas correctement. Est-ce vous pouvez m'expliquer ce que fait exactement la méthode moveToward? Est-ce que c'est la seule méthode qui permet de limiter un agent sur un nombre fini de cellules voisines?
Et puis je ne sais pas si je dois lier chaque berger à un point d'eau. Est-ce que vous pouvez m'aider à surmonter ce problème de faire limiter le berger sur un certain nombre de cellules tout autour d'un point d'eau fixe qui se trouve aussi sur une cellule.
Cordialement,
Abdou Fati.