/** * A class to represent an instance of the eight-puzzle. * * The…
Question Answered step-by-step /** * A class to represent an instance of the eight-puzzle. * * The… /*** A class to represent an instance of the eight-puzzle.** The spaces in an 8-puzzle are indexed as follows:** 0 | 1 | 2* –+—+—* 3 | 4 | 5* –+—+—* 6 | 7 | 8** The puzzle contains the eight numbers 1-8, and an empty space.* If we represent the empty space as 0, then the puzzle is solved* when the values in the puzzle are as follows:** 1 | 2 | 3* –+—+—* 4 | 5 | 6* –+—+—* 7 | 8 | 0** That is, when the space at index 0 contains value 1, the space* at index 1 contains value 2, and so on.** From any given state, you can swap the empty space with a space* adjacent to it (that is, above, below, left, or right of it,* without wrapping around).** For example, if the empty space is at index 2, you may swap* it with the value at index 1 or 5, but not any other index.** * * **/public class EightPuzzle implements SearchProblem> {private final List
>. ; /*** Creates a new instance of the 8 puzzle with the given starting values.** The values are indexed as described above, and should contain exactly the* nine integers from 0 to 8.** @param startingValues* the starting values, 0 — 8* @throws IllegalArgumentException* if startingValues is invalid*/public EightPuzzle(List
> getSuccessors(List


