static int CountNeighbors(ConsoleBuffer buffer, int x, int y) { return((buffer.GetUnitAttributes(x - 1, y) != black ? 1 : 0) + (buffer.GetUnitAttributes(x + 1, y) != black ? 1 : 0) + (buffer.GetUnitAttributes(x - 1, y + 1) != black ? 1 : 0) + (buffer.GetUnitAttributes(x + 1, y + 1) != black ? 1 : 0) + (buffer.GetUnitAttributes(x - 1, y - 1) != black ? 1 : 0) + (buffer.GetUnitAttributes(x + 1, y - 1) != black ? 1 : 0) + (buffer.GetUnitAttributes(x, y + 1) != black ? 1 : 0) + (buffer.GetUnitAttributes(x, y - 1) != black ? 1 : 0)); }