Setting new value in a grid
<p>I have a strange issue with an exercise I'm doing (game of life). In the middle bit of code, the line nextgeneration.set(livex, livey, live); causes the program to stop running. Any ideas? </p>

<pre><code>int lifeGenerator(Grid&lt;int&gt;&amp; nextgeneration, Grid&lt;int&gt;&amp; birthsanddeaths) {
    for (int deadx = 0; deadx &lt; nrows; deadx++) {
        for (int deady = 0; deady &lt; ncols; deady++) {
            int dead = birthsanddeaths.get(deadx, deady);
            if (dead == -3) {
                nextgeneration.set(deadx, deady, 0);
                }
            }
        }
    for (int livex = 0; livex &lt; nrows; livex++) {
        for (int livey = 0; livey &lt; ncols; livey++) {
            int live = nextgeneration.get(livex, livey);
                if (live &gt; 0 &amp;&amp; live &lt; kMaxAge) {
                live++;
                nextgeneration.set(livex, livey, live);// this doesnt work....
                }
            }
        }
    for (int newx = 0; newx &lt; nrows; newx++) {
        for (int  newy = 0; newy &lt; ncols; newy++) {
            int born = birthsanddeaths.get(newx, newy);
            if (born == 3) {
                    nextgeneration.set(newx, newy, 1);
            }
        }
    }
    return 0;
}
</code></pre>
