Subject: Re: Extracting variable values from distant cells
From: Pierre (bommel@cirad.fr)
Date: Fri Sep 11 2009 - 23:59:23 CEST
Hello Veronica,
A given cell can access other cells of the grid by different ways :
- self spaceModel elementaryEntities will return an array of all the
cells of the grid
- self allLayersTo: 8 (or whatever integer) will return a collection of
8 layers of cells. So, each sub collection is a layer of cells and the
index is the distance to this layer.
Ex: layersCollection =
[1 ->#(self)
2 ->#(self neighbourhood)
3 -> #(layer 2)
4 -> #(layer 3) ...]
Then, from a given set of cells, you can then select the cell verifying
the characteristics of the arrival cell. Ex :
grid := self spaceModel elementaryEntities.
targetCells := grid select: [: cell | cell attributX = 3].
arrivalCell := CormasSelectRandomlyFrom: targetCells.
If you want to choose the nearest cell with the given caracteristics,
you can also use the following method:
self nearestCellVerifying: [:aCell | aCell attributX = 3].
Finally, if you want to add some constraints on the path between the
departure and the arrival cells, you can use :
self nearestCellVerifying: [:aCell | aCell attributX = 3]
constraintOnPath: [:aCell | aCell landCover ~= #water]
A simple demo model is attached to this e-mail.
Hope it helps...
Pierre
Veronica Crespo a écrit :
>
> Dear colleagues,
>
> We used Cormas to build a cellular automaton of a pest which disperses
> by jumping from a cell to a distant one depending on variables of both
> the arrival cell and the departure cell. Cells of interest can be
> anywhere in our grid depending on local variables.
>
> This is where it gets tricky because whereas we know how to take into
> account variables of our departure cell i, we cannot find a function
> that permits us to extract the variables from far away cells in each
> time step. We need some function in Cormas that would allow us to,
> being in a cell i/,/ know and use the variables (in our case a number
> in a layer) from another cell situated elsewhere in the grid in each
> specific time step.
>
> So we are open for suggestions if someone has done something similar
> or might know how to solve this problem.
>
> Best regards,
>
> Veronica
>
>
>
-- -------------------------------- Pierre Bommel - CIRAD - UR Green UnB - Faculdade de tecnologia. Departamento de engenharia mecânica Campus universitário Darcy Ribeiro Asa norte Brasília - DF tel : (00 55 61) 3208 3405 cel : (00 55 61) 8122 2878 http://www.cirad.fr/ur/green --------------------------------