Question: Consider a modified version of the 8-puzzle problem in which adjacent tiles that differ by one in value can be exchanged in addition to the
Consider a modified version of the 8-puzzle problem in which adjacent tiles that differ by one in value can be exchanged in addition to the allowed blank moves in the 4 directions: up, left, write and down
some one help me to write a code using best first search algorithm with a heuristic
this is the algorithm :
Best First search Algorithm
Repeated states are not allowed
// The algorithm is capable of finding the path to the goal state
Steps:
1. create a list of nodes called OPEN containing one node representing the initial state of the problem. Compute h value for the node.
2. create an empty list of nodes called CLOSED.
3. while (OPEN is not empty) do {
3.1. N=the node in OPEN having best h value.
3.2. Delete N from OPEN;
3.3 add N to CLOSED.
3.4 if N contains a goal state return N and the solution.
3.5. E=expand(N); // E is the set of states that result from applying the operators to the state inside N
3.6. for every state i in E do{
compute h(i);
if (i is not neither in any OPEN node nor in any CLOSED node){
Create a node for i and add it to OPEN;
Make i point to N which is on the CLOSED list;
}//if
}//for
}//while
4. return failure.

Write the program in either C++ or Java. The program when executed must ask the user to enter the text file name containing the initial state and goal state of the problem. Assume that the input file is always formatted as (just an example) using best first search You need to come up with a heuristic b 4 5 3 16 initial state 8 7 1 2 3 4 5 6 goal state 7 8 The program should output for each of the two algorithms: 1. The solution expressed as sequence of operations. 2. Number of states expanded
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
