package net.gpdev.gameoflife;

public class GameOfLife {
    private final int xDim;
    private final int yDim;

    private Grid current;
    private Grid next;

    public GameOfLife(int xDim, int yDim) {
        this.xDim = xDim;
        this.yDim = yDim;
        current = new Grid(xDim, yDim);
        next = new Grid(xDim, yDim);
    }

    public void populateCell(int x, int y) {
        current.set(x, y);
    }

    public boolean isCellPopulated(int x, int y) {
        return !current.isEmpty(x, y);
    }

    public void tick() {
        for (int i = 0; i < xDim; i++) {
            for (int j = 0; j < yDim; j++) {
                if (current.isEmpty(i, j)) {
                    if (current.numNeighbors(i, j) == 3) {
                        next.set(i, j);
                    }
                }
                else {
                    final int numNeighbors = current.numNeighbors(i, j);
                    if (numNeighbors == 2 || numNeighbors == 3) {
                        next.set(i, j);
                    }
                }
            }
        }
        current = next;
    }

    @Override
    public String toString() {
        return current.toString();
    }
}

@@ -760,32 +760,103 @@
 next.set(i, j);%0A
+                    %7D else %7B%0A                        next.unset(i, j);%0A
                 
@@ -878,32 +878,16 @@
        %7D
-%0A               
  else %7B%0A
@@ -1057,32 +1057,103 @@
 next.set(i, j);%0A
+                    %7D else %7B%0A                        next.unset(i, j);%0A
                 
@@ -1191,32 +1191,68 @@
      %7D%0A        %7D
+%0A%0A        final Grid prev = current;
 %0A        current
@@ -1260,16 +1260,37 @@
 = next;%0A
+        next = prev;%0A
     %7D%0A%0A 

Correct game.tick() implementation and pass failing test