title: C++ Game of Life, difficulty reproducing next generations
body: <p>Currently try to create the game of life, it outputs all the generations (6) and takes in the user input (or if chosen to do automatically), but the next generation after the initial population is not updating following the game of life rules but rather staying the same as the initial population:</p>
  <p>Rules:</p>
  <ol>
  <li>Any live cell with fewer than two live neighbours dies, as if by underpopulation.</li>
  <li>Any live cell with two or three live neighbours lives on to the next generation.</li>
  <li>Any live cell with more than three live neighbours dies, as if by overpopulation.</li>
  <li>Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.</li>
  </ol>
  <p>Any help in fixing this mistake would be appreciated!</p>
  <pre class="lang-cpp prettyprint-override"><code>// Produce the next generation
  void reproduce(int grid[][m]){
      int newGrid[n][m];
      
      for (int i=0; i&lt;n; i++) {
          for (int j=0; j&lt;m; j++) {
              newGrid[i][j] = grid[i][j]; // Copying old grid to a new grid
          }
      }
      
      // Applying rules for next generation
      for (int i=0; i&lt;n; i++) {
          for (int j=0; j&lt;m; j++) {
              int cellNeighbours = countNeighbours(grid, i, j);
              
              // Live cell rules
              if (cellNeighbours &lt; 2 &amp;&amp; grid[i][j] == 1) {
                  newGrid[i][j] == 0;
              }
              if (cellNeighbours &gt; 3 &amp;&amp; grid[i][j] == 1) {
                  newGrid[i][j] == 0;
              }
              if (cellNeighbours == 2 &amp;&amp; grid[i][j] == 1) {
                  newGrid[i][j] == 1;
              }
              if (cellNeighbours == 3 &amp;&amp; grid[i][j] == 1) {
                  newGrid[i][j] == 1;
              }
              
              // Dead cell rules
              if (cellNeighbours == 3 &amp;&amp; grid[i][j] == 0) {
                  newGrid[i][j] == 1;
              }
          }
      }
  }
  </code></pre>