title: Java Game of Life not checking neighbors correctly
body: <p>I set an initial pattern of cells (<a href="http://i.stack.imgur.com/MAf5v.png" rel="nofollow">initial state screenshot</a>) for my game of life to evolve, but the code does not seem to evolve the cells correctly. Instead, it stops <a href="http://i.stack.imgur.com/X3trP.png" rel="nofollow">here</a>, but this generation should not look like this. (I apologize for the inconvenience, but I cannot post what the state should look like due to lack of reputation).  I've looked through my evolution method, but I can't seem to find the problem since I believe all of the surrounding cells are accounted for. Help is much appreciated.</p>
  
  <pre><code>public void setCellAlive (int row, int col){
  if (row &lt;= numberRows){
            colony [row][col] = 1;
      }else{
      System.out.println ("Index out of range.");
      }
  }
  public void setCellDead (int row, int col){
      if (row &lt;= numberRows){
          colony [row][col]=0;
      }else{
           System.out.println ("Index out of range.");
      }
  }
  private void evolution(int i, int j) {
      int left = 0, right = 0, up = 0, down = 0;
      int topLeft = 0, topRight = 0, bottomLeft = 0, bottomRight = 0;
  
      if (j &lt; colony.length - 1) {
          right = colony[i][j + 1];
          if(i&gt;0)
              bottomRight = colony[i - 1][j + 1];
          if (i &lt; colony.length - 1)
              topRight = colony[i + 1][j + 1];
      }
  
      if (j &gt; 0) {
          left = colony[i][j - 1];
          if (i &gt; 0)
              bottomLeft = colony[i - 1][j - 1];
          if (i&lt; colony.length-1)
              topLeft = colony[i + 1][j - 1];
      }
  
      if (i &gt; 0)
          up = colony[i + 1][j];
      if (i &lt; colony.length - 1)
          down = colony[i - 1][j];
  
      int sum = left + right + up + down + topLeft + topRight
              + bottomLeft + bottomRight;
  
      if (colony[i][j] == 1) {
          if (sum &lt; 2)
              setCellDead (i,j);
          if (sum &gt; 3)
              setCellDead(i,j);
      }
  
      else {
          if (sum == 3)
              setCellAlive (i,j);
      }
  
  }
  public void updateColony() {
      for (int i = 0; i &lt; colony.length; i++) {
          for (int j = 0; j &lt; colony[i].length; j++) {
              evolution(i, j);
          }
      }
   }
  </code></pre>