On 16 January 2018 at 05:47, Nicolai Hess <[email protected]> wrote:
>
>
> 2018-01-15 18:04 GMT+01:00 Photon <[email protected]>:
>>
>> when I call the countNeighbours method i get an error: the block wants two
>> arguments but I pass only one.
>> This is probally because i want to pass x y but only really pass x wich
>> ends
>> up being a cell and not the index.
>>
>> I still have trouble thinking it trough. The indicieDo: method seems to
>> make
>> the matrix bigger?! I  don`t quite understand it.
>
>
> It should not, and looking at the implementation, it just iterates with two
> loops 1 to number of rows times 1 to number of columns and calls your
> block argument with the pair of indexes.
>
>>
>>
>> There must be an easy way to to figure out if the suroundings are alive or
>> not. I mean its all there what I need and in my mind its so easy to
>> discribe
>> it with normal words. But to tell the machine witth syntax is another
>> thing
>> really :/
>
>
> About the surroundings, there is a nice method in Point
> Point>>eightNeighbors, that gives you the coordinates of the eight
> surrounding fields
> for example:
> (5@7) eightNeighbors  "{(6@7). (6@8). (5@8). (4@8). (4@7). (4@6). (5@6).
> (6@6)}"


@all, side-question...
I remember from Squeak Lasergame tutorial that it represented a grid
as a Dictionary rather than an Array of Arrays.
http://squeak.preeminent.org/tut2007/html/032.html
  #initializeCells

Anyone have an opinion of the suitability of that approach in relation
to grid sizing?

cheers -ben

>
> with this method and if you iterate through all pairs of indices of the
> matrix, you can
> do your computation for every point, but you have to take care about the
> points that don't
> have valid matrix indices for some of their neighbours (like 0@0, the left
> and top neighbours
> may actually "on the other side of the matrix"). But you can take a look at
> SequenceableCollection>>atWrap: how it deals with "wrapping around".
>
>
>
>>
>>
>> what if i selected only one element with do:[] and let its tell me its
>> idices. I store them in a temp object and then I check outside the block
>> the
>> neighbours and add to the counter. Once this is done I repeat as many
>> times
>> as their elements in the matrix?
>>
>> Greetings

Reply via email to