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 canSlideLeft() { return emptySpace.getX() != (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 canSlideRight() { return emptySpace.getX() != 0; }