I'm reading this in gmail.�� After "this method work:" I see a gap with nothing visible.
After "wich looks like this" there is again a gap with nothing visible.��

Recalling that the Life universe is an *infinite* two-dimensional space, you want a data
structure that naturally grows to be as big as it needs to be and no bigger.�� I ran across
a similar problem last year.�� A Dictionary[Integer->Dictionary[Integer->State]] turned
out to work very well.�� You could also use a Dictionary[Point[Integer,Integer] -> State]
which would be logically�� simpler.�� The key idea is that you don't want to iterate over
all the cells, only the cells which are live.�� Now the states in Life are very simple,
so the data structure you want is actually a Set[Point[Integer,Integer]].�� The only
cells that can change state are the live cells and the dead (not present in the set) that
are king-wise adjacent to a live cell.���� So you will be doing something like
������ candidates := Bag new.
������ dyingCells := Set new.
������ liveCells do: [:each |
�������������� n := 0.
�������������� each kingwiseNeighboursDo: [:neighbour |
������������������ (liveCells includes: neighbour)
������������������������ ifTrue: [n := n + 1]
������������������������ ifFalse: [candidates add: Bag]]
�������������� (n between: 2 and: 3) ifFalse: [dyingCells add: each].
������ liveCells removeAll: dyingCells.
������ candidates valuesAndCounts keysAndValuesDo: [:each :count |
�������������� count = 3 ifTrue: [liveCells add: each]].
WARNING: This code has not been tested.

On 16 January 2018 at 03:29, Photon <nico-braun@live.de> wrote:
Hello folks,

I am trying since yesterday to make a game of life implemenation work. It
looks all ok so far but in can`t figure out the final steps. I think I get
the logic I have to use and if I imagine the code in C++ for example it
would be pretty much straight forward. But with pharo I got trouble telling
the machine what I want.

In short I`m trying to make this method work:



I wrote a test wich looks like this:



I want to go trough each element of the matrix(cells), check its surounding
cells if they are alive, and set its counter if there are any living
neighbours. It should move like this through the whole matrix to set the
neighbour counter for each element.

In this method i just tried the implement the topLeft check yet but I think
you get the idea. You can look at the comment�� in the top section it shows
where the neighbour indexes are.

I tried so many things by now, did research read methods of the superclasses
but I can`t make it work.
I woud be really glad if someone gave me a little hint. What is wrong here?



--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html