Morton said:
I am not sure I understand what you are asking. If you want to look
in a neighborhood around a cell that is two cells deep, shouldn't the
deltas be given by
Well i'll try to explain very very short what i need...
See my representation of a grid (now don't laugh
)
All the 1's stand for cell with celltype road...
x x x 1 o o o 1
x 2 x 1 o o o 1
x x x 1 o o o 1
1 1 1 1 1 1 1 1
o o o 1 o o o 1
o o o 1 o o o 1
o o o 1 o o o 1
Let's concentrate on the number 2 in the top left 'segment' of the grid
and it's surrounding x's. Let the 2 stand for a cell with celltype
housing...the x's are also given a celltype of 2 ór 3, but i haven't
displayed them here...in the code this is done by the 60 and 40 percent
thingy...
For the celltypes 2 and 3 I have preference scores like this:
Table for celltype 2: housing
---------------------------------------
regarding type: preference score:
celltype 1 12
celltype 2 12
celltype 3 8
Table for celltype 3: green environment
---------------------------------------
regarding type: preference score:
celltype 1 3
celltype 2 8
celltype 3 12
Now i need something that reads the celltypes of the x's, or so to say
of the cells which touch the '2 cell'. Then when it has read all the
celltypes it needs to add all the preference scores of those celltypes
(gathered out of the table of the central cell, in this case Table for
celltype 2: housing.
Example: there are 8 x'es or 8 cells surrounding that 2 cell. Let five
of them be of celltype 2 and the remaining three of them are celltype 3.
Then I, or better the program
, need(s) to calculate a score of:
5 x (score of celltype 2 in table 2) = 5 x 12 = 60
3 x (score of celltype 3 in table 2) = 5 x 8 = 40
---------------------------------------------------
Total adjacency score of this cell = 100
So I need to really only have the cells which are in a distance range of
1 of some cell.
The above is an explanation of the step I need to find out, below
follows a small explanation of how the total system should work. So ONLY
read the below if you're interested, its just a further explanation of
what my end goal is.
------------------------------------------------------------------------------
The above should be processed as follows.
For the first and second cell ([0,0] and [1,0] OR [0,0] and [0,1], my
teacher and I dont think it should matter in the end, because all cells
are going to be switched, troughout the algorithm) the above scores
should be calculated.
surrounding cells for cell 1 and cell 2:
-----------------------------------------
2 x x x
x x 3 x
x x
STEP 1:
It needs to calculate a total adjacency score for cell 1 (3 x's), from
table for celltype 2, and a total adjacency score of cell 2 (5 x's),
from table for celltype 3. Then the total of these two subtotals is
calculated (this first random filled situation represents just a random
filling of space with housing and green).
STEP 2: Now the celltypes of cell 1 and cell 2 are switched and the new
subtotals are calculated (this switch represents a new situation):
3 x x x
x x 2 x
x x
If the total of the two subtotals in this switched situation is higher
than the total of step 1, then the cells stay switched, if it's lower
then we have to switch back.
So to say we look if the suitability of the switched situation is higher
as the old situation, if so let the cells keep the higher suitability,
if not switch back to the old situation with higher suitability.
After this decision (wether the cells are switched or not, that doesnt
matter) cell 1 and cell 3 are looked at and the two steps are taken
again. Again look if switching has a higher suitability, if so keep the
switch between cell 1 and 3, otherwise switch back.
Then cell 1 and 4
Then cell 1 and 5
etc. until the last cell is looked at.
-------------------------------------------------------------------------------
** When going through the cells all cells with celltype = 1 have to be
skipped (hence the locked status) because these stand for roads which
are predefined in the planning area and should not be switched. They are
in fact regarded when they act as surrounding cells because we want for
example to get the housing cells located near the road cells (houses in
Holland are usually located at a street ;-) )
-------------------------------------------------------------------------------
After that, we start with cell 2 and cell 3, cell 2 and cell 4, cell 2
and cell 5 etc. After that cell 3 and cell 4, cell 3 and cell 4, cell 3
and cell 5 etc.
The main idea is that this algorithm should calculate the ultimate
suitability of a plan area which has to be developed with housing and
green at the hand of preference scores. As you see in the text, it is a
real pain if you would have to do this by hand so that's why we try to
develop some system...Furthermore if I get this to work, then we can
expand the different celltypes, tables, preference scores etc to a more
sophisticated system.
Anyways I hope this all makes a bit sense...I had it in a word file
explained earlier but now with the help of this text maybe you guys get
a better view at the problem...
Sorry for the size of my reply, but when I start typing I have the
tendacy to get a bit abundant
...
Greets, Joop