GameOfLife { public static boolean[][] live(boolean[][] world) { final boolean[][] result = blankWorld(world.length); for (int i = 1; i < world.length - 1; i++) { for (int j = 1; j < world.length - 1; j++) { result[i][j] = cellState(world[i][j], numberOfNeighbours(world, i, j)); } } return result; }  static boolean[][] blankWorld(int size); static boolean[][] live(boolean[][] world); static final boolean _; static final boolean X; }
@Test public void it_blinks_the_blinker() { final boolean[][] state = { { _, _, _, _, _ }, { _, _, X, _, _ }, { _, _, X, _, _ }, { _, _, X, _, _ }, { _, _, _, _, _ } }; assertArrayEquals(new boolean[][] { { _, _, _, _, _ }, { _, _, _, _, _ }, { _, X, X, X, _ }, { _, _, _, _, _ }, { _, _, _, _, _ } }, GameOfLife.live(state)); }