I am creating an A* search method for my programming task. My issue is that an A* search method is supposed to find the lowest cost path and always find the goal state. However, my code does not solve the problem for certain puzzles. For example, for the puzzle:
*=====*
||103||
||426||
||758||
*=====*
The required goal state is reached, however for a puzzle with more tiles out of place. For example for the puzzle:
*=====*
||104||
||326||
||758||
*=====*
The following error is produced:
Step: 3073
*=====*
||016||
||342||
||758||
*=====*
Exception in thread "main" java.lang.StackOverflowError
at sun.nio.cs.UTF_8$Encoder.encodeLoop(UTF_8.java:680)
at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:579)
at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:271)
at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:125)
at java.io.OutputStreamWriter.write(OutputStreamWriter.java:207)
at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:129)
at java.io.PrintStream.write(PrintStream.java:526)
at java.io.PrintStream.print(PrintStream.java:669)
at java.io.PrintStream.println(PrintStream.java:806)
My code can be found here: http://pastebin.com/rwq3cTAq