Messages from list : cormas@cirad.fr

Choose a topic among the following archives :

accessing a cell of neighborhood containing another agent

New Message Reply Date view Thread view Subject view Author view

Subject: accessing a cell of neighborhood containing another agent
From: Pierre-Marcel GORAL (corran_pmg@hotmail.com)
Date: Fri Mar 12 2004 - 17:00:20 CET

 Hello everybody!
Proceeding with the secund tutorial of the CIRAD site, I've tried to ameliorate the model Forager-Plant by introducing Predators. I'm a very beginner in Cormas, so excuse me if the answer to my problem is trivial  ;-) .
The problem is to make a predator go to a cell of its neighbourhood where there is a prey for him. I've tried to use several function, but it seems that ther aren't the good ones: a major bug is often : "smthing must be Boolean", or even "proceed for truth"! It seems, so, that I couldn't use properly "theOccupants at", for example. I tried also to go on with "perceivedEntities", but I got the same kind of error messages.
Here is my last version of the code:

MOVE 

| preyNeighbours |
 "BUG!!! trouver une fonction identifiant le fait qu'une cellule soit occupée par un agent de classe Forager"
 preyNeighbours := self patch neighbourhood select: [:cell | cell theOccupants at: #Forager ].
 preyNeighbours isEmpty
  ifTrue: [self randomWalk]
  ifFalse: [self leave. self moveTo: (Cormas selectRandomlyFrom: preyNeighbours)].

It'll be nice of you if you pay attention to this problem, because it's really annoying not finding solution to such a simple but important function.


Nothing less to the Zero fighter! 

Pierre-Marcel GORAL



Trouvez l'âme soeur sur MSN Rencontres. Cliquez-ici

New Message Reply Date view Thread view Subject view Author view
 

Back to home