NearAnotherStone implements Predicate { @Override public boolean at(short p) { for (final short q : neighborhoods[p]) { if (board.getColorAt(q) != VACANT) { return true; } } return false; } NearAnotherStone(Board board); @Override boolean at(short p); static final short[][] OFFSETS; }
@Test public void testAt() { String[] before = { "#....", ".....", ".....", ".....", ".....", }; board.setUpProblem(before, BLACK); assertFalse(nearAnotherStone.at(at("e4"))); assertTrue(nearAnotherStone.at(at("b5"))); assertTrue(nearAnotherStone.at(at("c3"))); assertTrue(nearAnotherStone.at(at("b2"))); }
@Test public void testClear() { String[] before = { "#....", ".....", ".....", ".....", ".....", }; board.setUpProblem(before, BLACK); board.play("a2"); assertFalse(nearAnotherStone.at(at("e5"))); assertTrue(nearAnotherStone.at(at("b5"))); assertTrue(nearAnotherStone.at(at("c3"))); board.clear(); assertFalse(nearAnotherStone.at(at("a4"))); }