Conway's game of life

FG via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Feb 1 14:51:39 PST 2015


On 2015-02-01 at 22:00, gedaiu wrote:
> I implemented Conway's game of life in D.

I think you are playing a different game here.

     /// Count cell neighbours
     long neighbours(Cell myCell, CellList list) {
         long cnt;
         foreach(cell; list) {
             auto diff1 = abs(myCell.x - cell.x);
             auto diff2 = abs(myCell.y - cell.y);
             if(diff1 == 1 || diff2 == 1) cnt++;   // Why || instead of && ???
         }
         return cnt;
     }


More information about the Digitalmars-d-learn mailing list