15 puzzle solver: Difference between revisions

Content added Content deleted
m (Small code improvement.)
m (Small coding improvements.)
Line 6,376: Line 6,376:
private static class Puzzle {
private static class Puzzle {


public Puzzle(List<Integer> aTiles, List<String> aMoves, int aZeroIndex, long aSearchDepth) {
public Puzzle(List<Integer> aTiles, List<String> aMoves, int aZeroIndex, int aSearchDepth) {
tiles = aTiles;
tiles = aTiles;
moves = aMoves;
moves = aMoves;
Line 6,421: Line 6,421:
System.out.println();
System.out.println();
}
}

@Override
public int hashCode() {
int hash = 3;
hash = 23 * hash + tiles.hashCode();
hash = 23 * hash + zeroIndex;
return hash;
}


@Override
@Override
Line 6,436: Line 6,428:
case Object object -> false;
case Object object -> false;
};
};
}
@Override
public int hashCode() {
int hash = 3;
hash = 23 * hash + tiles.hashCode();
hash = 23 * hash + zeroIndex;
return hash;
}
}
Line 6,441: Line 6,441:
private List<String> moves;
private List<String> moves;
private int zeroIndex;
private int zeroIndex;
private long searchDepth;
private int searchDepth;
private static final List<Integer> GOAL = List.of( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0 );
private static final List<Integer> GOAL = List.of( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0 );