private void swapWithEmpty(int[][] newLayout, int destX, int destY) { newLayout[(int) emptySpace.getY()][(int) emptySpace.getX()] = newLayout[destY][destX]; newLayout[destY][destX] = EMPTY_SPACE; }
private boolean canSlideUp() { return emptySpace.getY() != (n - 1); }
private NPuzzleState slideLeft() { int[][] copyOfLayout = TwoDArrayUtils.makeCopy(layout); swapWithEmpty(copyOfLayout, (int) emptySpace.getX() + 1, (int) emptySpace.getY()); return new NPuzzleState(copyOfLayout, n); }
private boolean canSlideDown() { return emptySpace.getY() != 0; }