Messages from list : cormas@cirad.fr

Choose a topic among the following archives :

RE : Create more agents in a specific plot

New Message Reply Date view Thread view Subject view Author view

Subject: RE : Create more agents in a specific plot
From: Christophe Le Page (christophe.l@chula.ac.th)
Date: Tue Apr 04 2006 - 07:31:05 CEST

 

Dear Warong,

 

From the way you describe your model, it seems that the "Villager" entity is
more a "Household". I suggest you:

 

1. to rename “Villager” into “Household”

2. to create a new entity called "FamilyMember", a kind of AgentLocation.

3. to add 2 new attributes of the "Household" entity:

* familySize (default value: 3 or any suitable integer value)

* familyMembers (default value: IndexedSet new).

4. to add the following lines in the "init" method of "Household"

...

self familySize timesRepeat:

[self familyMembers add: (self createEntity: FamilyMember new)].

5. to write the “initHouseholds” at the level of the model like this:

initHouseholds

|location|

self households do: [:h |

      h init. ”if not done before…”

location := Cormas selectRandomlyFrom: h myCells.

h famillyMembers do: [:fm | fm moveTo: location]].

 

Sawatdee!

Clp

 

 

> -----Message d'origine-----

> De : owner-cormas@cirad.cirad.fr [mailto:owner-cormas@cirad.cirad.fr] De

> la part de warong@agri.ubu.ac.th

> Envoyé : mardi 28 mars 2006 14:06

> À : cormas@cirad.fr

> Objet : Create more agents in a specific plot

>

> Dear all,

> I have a trouble to add agents in spatial grid of Cormas. I implemented 11

> plots belonging to individual family. What I am trying to do is to add and

> display family members in each plot. What I can do now is adding only one

> family member (agent) into plot (spatial grid) by writing code

>

> In class Villager

>

> myCells

> |selectedCells|

> selectedCells := OrderedCollection new.

> self plots do: [: pl | pl components do: [:c selected Cells add: c]].

> ^selectedCells

>

> In control and scheduler

>

> initVillagers

> |location|

> self villagers do: [:v | location := Cormas selectRandomlyFrom: v myCells.

> v

> moveTo: location].

>

> I am looking for a pre-defined method that allows me to add more agents

> into

> a selected plot (cells) but I could not find it.

> Do you have any suggestion?

> Thanks.

>

> Warong

 

New Message Reply Date view Thread view Subject view Author view
 

Back to home