As sean4u pointed out hashmap uses hash tables i.e (key,value) pair, so it is not sorted in any way. Interestingly it seems it is non-deterministic as well (you get different sequence every time you...
Type: Posts; User: dabdi
As sean4u pointed out hashmap uses hash tables i.e (key,value) pair, so it is not sorted in any way. Interestingly it seems it is non-deterministic as well (you get different sequence every time you...
Yes proper back propagation is required for more complex goals. The OP's problem is very simple as to not require advanced solutions. He can even use a longjump once he encounters a goal at a leaf...
You have isGoalState inside the for loop as well so make the same change.
// recursively expands search space
output = recursiveExpandNode( current );
if( problem.isGoalState(...
Did you try my suggestion ? It is pretty straight forward and I can not see why it will not work.
Declare a member variable goalFound.
Boolean goalFound;
Set it to false initially (in...
I think your termination criteria is wrong. You should unwind the recursion when a goal is found anywhere in the tree (not just when the current node is a goal). A simple solution is to have a...