NotEyeLike implements Predicate { @Override public boolean at(short p) { assert board.getColorAt(p) == VACANT; final StoneColor color = board.getColorToPlay(); if (!board.hasMaxNeighborsForColor(color, p)) { return true; } int count = edgeEnemies[p]; final StoneColor enemy = color.opposite(); final short[] neighbors = board.getCoordinateSystem().getNeighbors(p); for (int i = FIRST_DIAGONAL_NEIGHBOR; i <= LAST_DIAGONAL_NEIGHBOR; i++) { if (board.getColorAt(neighbors[i]) == enemy) { count++; if (count >= 2) { return true; } } } return false; } NotEyeLike(Board board); @Override boolean at(short p);  }
@Test public void testCorner() { String[] before = { ".#...", "#O...", ".....", "#...O", ".#.O.", }; board.setUpProblem(before, BLACK); assertFalse(notEyeLike.at(at("a1"))); assertTrue(notEyeLike.at(at("e1"))); assertTrue(notEyeLike.at(at("a5"))); assertTrue(notEyeLike.at(at("a3"))); }
@Test public void testEdge() { String[] before = { ".O.O.", "..O..", ".....", "..O#.", ".O.O.", }; board.setUpProblem(before, WHITE); assertFalse(notEyeLike.at(at("c5"))); assertTrue(notEyeLike.at(at("c1"))); }
@Test public void testCenter() { String[] before = { ".....", ".#O#.", "#.#.#", ".#.#O", ".....", }; board.setUpProblem(before, BLACK); assertFalse(notEyeLike.at(at("b3"))); assertTrue(notEyeLike.at(at("d3"))); assertTrue(notEyeLike.at(at("c2"))); }