Subject: [Fwd: Re: How to restrict initAgents?]
From: Romain Lorrilliere (romain.lorrilliere@ese.u-psud.fr)
Date: Mon Mar 06 2006 - 15:16:51 CET
Hello Mira.
If you want to restrict the cell for the agent initialisation, you can't
use this méthode
self setRandomlyLocatedAgents: n:
Try this :
100 timesRepeat:[(self newEntity: Tourist) init].
destinations := OrderedCollection new.
destination := self theCells select: [:cell| cell state = #Lands
or:[cell state = #streets]].
self theTourists do:[ :t| t moveTo: (CormasRandomlyFrom: destinations)].
Good luck
Romain
Lorrillière Romain
UMR 8079 Laboratoire Ecologie, Systématique et Evolution
Bât. 362
Université Paris-Sud
91405 Orsay cedex
France
tel : 01 69 15 56 85
fax : 01 69 15 56 96
mobile : 06 81 70 90 70
email : romain.lorrilliere@ese.u-psud.fr
Miao Wang wrote:
>Hi all!
>
>I have imported a map into Cormas and I'm trying to simulate crowds walking in the streets.Now I have some problems:
>
>according to the tutorial, after I identified the intAgents in instance-creation like this
>
>initAgents
> super initAgents.
> self setRandomlyLocatedAgents: Tourist n:100
>
>The 100 agents are ramdomly standing all over the visualisation space window ,no matter which attibute the cell has(river or building or even out of the map(no value area)).But what I want is just to let the 100 agents been restricted in cells with attributes of 'lands' or 'streets'.
>
>I thought a conditonal test is needed. so I add:
>
>super initAgents.
> self patch state=#Lands ifTrue:[self setRandomlyLocatedAgents: Tourist n:100].
>
>But Cormas show:
>
>"Unhandled exception:message not understood:#patch."
>
>Is there anyone who can give me some idea about it?
>
>Thank you very much!
>
>Mira
>
>
>
>
>
>
--Lorrillière Romain
UMR 8079 Laboratoire Ecologie, Systématique et Evolution
Bât. 362
Université Paris-Sud
91405 Orsay cedex
France
tel : 01 69 15 56 85
fax : 01 69 15 56 96
mobile : 06 81 70 90 70
email : romain.lorrilliere@ese.u-psud.fr