neighbors method

Neighbors neighbors(
  1. int x,
  2. int y
)

Implementation

Neighbors neighbors(int x, int y) {
  final val = get(x, y);
  return Neighbors(
    topLeft: x > 0 && y > 0 && get(x-1, y-1) == val,
    top: y > 0 && get(x, y-1) == val,
    topRight: y > 0 && x < width-1 && get(x+1, y-1) == val,
    left:  x > 0 && get(x-1, y) == val,
    right: x < width - 1 && get(x+1, y) == val,
    bottomLeft: x > 0 && y < height-1 && get(x-1, y+1) == val,
    bottom: y < height -1 && get(x, y+1) == val,
    bottomRight: x < width - 1 && y < height -1 && get(x+1, y+1) == val
  );
}