2018-01-15 15:29 GMT+01:00 Photon <[email protected]>: > 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? >
I Photon, what exaclty get wrong ? Do you have an error message or is just the result not what you expected? Iterating over a matrix with do: would iterate over the whole contents of the matrix and the do block gets only called with a single value (the actual element). If you want to iterate over the indices (x/y) you can take a look at the method Matrix>>indicesDo: . Or if it does not match what you are looking for, check out the other methods in Matrix 'enumeration' protocol. nicolai > > > > -- > Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html > >
