private void swapWithEmpty(int[][] newLayout, int destX, int destY) { newLayout[(int) emptySpace.getY()][(int) emptySpace.getX()] = newLayout[destY][destX]; newLayout[destY][destX] = EMPTY_SPACE; }
@Override public boolean isGoalReached(MazeState currentState) { return goalPosition.equals(currentState.getPosition()); }
private NPuzzleState slideLeft() { int[][] copyOfLayout = TwoDArrayUtils.makeCopy(layout); swapWithEmpty(copyOfLayout, (int) emptySpace.getX() + 1, (int) emptySpace.getY()); return new NPuzzleState(copyOfLayout, n); }
private boolean canSlideLeft() { return emptySpace.getX() != (n - 1); }
private boolean canSlideRight() { return emptySpace.getX() != 0; }
private boolean canSlideUp() { return emptySpace.getY() != (n - 1); }
private boolean canSlideDown() { return emptySpace.getY() != 0; }