int count = 0;
for(int x = 1; x < 79; x++)
{
for(int y = 1; y < 21; y++)
{
char surroundingCells[] = {arr[x-1][y-1], arr[x][y-1], arr[x-1][y], arr[x+1][y+1], arr[x+1][y-1], arr[x-1][y+1], arr[x][y+1], arr[x+1][y]};
for(int z = 0; z < 8; z++)
{
if((surroundingCells[z] == 'x' || surroundingCells[z] == 'd') && arr[x][y] == 'x')
count++;
else if((surroundingCells[z] == ' ' || surroundingCells[z] == 'l') && arr[x][y] == ' ')
count++;
}
if(arr[x][y] == 'x' && (count != 2 || count != 3))
arr[x][y] = 'd';
else if(arr[x][y] == ' ' && count == 3)
arr[x][y] = 'l';
count = 0;
}
}
when i print the array after this code is run all the places where there was an x has a 'd' but that shouldnt occur some instances allow for an 'x' to remain. Can someone see my logical error?