Messages from list : cormas@cirad.fr

Choose a topic among the following archives :

RE : accessing a cell of neighborhood containing another agent

New Message Reply Date view Thread view Subject view Author view

Subject: RE : accessing a cell of neighborhood containing another agent
le_page@cirad.fr
Date: Fri Mar 12 2004 - 18:50:05 CET

Bonjour Pierre-Marcel,

The argument of the "select" method is a block where the instruction has to be a
boolean (a test). In your case,
    (cell theOccupants at: #Forager),
is a collection. You simply have to check if this collection is not empty:
    (cell theOccupants at: #Forager) isEmpty not

In your last line, you can remove "self leave", which is here unnecessary, as it
has been set as the first instruction of the "moveTo:" method.

You may have a look to the didactic Cormas model specially designed to learn
about this kind of predators-preys interactions:
http://cormas.cirad.fr/fr/applica/pursuit.htm

Bonne continuation avec Cormas !
clp

-----Message d'origine-----
De : owner-cormas@cirad.fr [mailto:owner-cormas@cirad.fr] De la part de
Pierre-Marcel GORAL
Envoyé : vendredi 12 mars 2004 17:00
À : cormas@cirad.fr
Objet : accessing a cell of neighborhood containing another agent

 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.

New Message Reply Date view Thread view Subject view Author view
 

Back to home