15 puzzle solver: Difference between revisions

Content added Content deleted
Line 4,615: Line 4,615:


The more weight given to the heuristics, the less number of states are explored, with the trade off that solution becomes not optimal (longer than expected). As you can see on the output, we found minimum solution for the easy problem, meanwhile with above setting the hard problem was not really solved, it explore only few states and found an unoptimal solution with 106 length.
The more weight given to the heuristics, the less number of states are explored, with the trade off that solution becomes not optimal (longer than expected). As you can see on the output, we found minimum solution for the easy problem, meanwhile with above setting the hard problem was not really solved, it explore only few states and found an unoptimal solution with 106 length.

===Implementation===
<lang Scala>
<lang Scala>
import scala.collection.mutable
import scala.collection.mutable
Line 4,714: Line 4,716:
</lang>
</lang>


===Output===
{{out}}

<pre>Exploring 698181 states, found solution with length 52 for board:
<pre>Exploring 698181 states, found solution with length 52 for board:
Weighted heuristic used 5 * heuristic + 4 * travel.
Weighted heuristic used 5 * heuristic + 4 * travel.