15 puzzle using 2d arrays
I made a basic (not very efficient) algorithm to solve a 15-puzzle using bfs.
Each node is a puzzle-state.
I assume I'm doing something wrong, because the puzzles.size() runs over 30000+
I'd really appreciate it if someone could take a look.
It should basically go:
Code:
new queue, add rootNode
while (queue != empty){
Node n = firstFromQueue
if ( n matches goalState)
succes
else
add n.successors to queue
but also keep track of the nodes visited, because you don't need to visit them again.