@Test public void rightMoves2() { Puzzle puzzle = new Puzzle(generator.generate3x3()); while (!determiner.puzzleIsSolvable(puzzle)) { puzzle = new Puzzle(generator.generate3x3()); } Puzzle copy = puzzle.copy(); idastar = new IDAStar(puzzle); List<Move> moves = idastar.solve(); for (int i = 0; i < moves.length(); i++) { copy.move(moves.get(i)); } boolean isInGoalState = true; int k = 1; for (int i = 0; i < copy.n(); i++) { for (int j = 0; j < copy.n(); j++) { if (copy.valueAtPoint(j, i) != k && k != copy.n() * copy.n()) { isInGoalState = false; } k++; } } assertTrue(isInGoalState); }