Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

#include #include #include GRAPH _ SEARCH.h #include data _ types.h int main ( ) { Node root, * goal; State * goal _

#include
#include
#include "GRAPH_SEARCH.h"
#include "data_types.h"
int main()
{
Node root, *goal;
State *goal_state = NULL;
enum METHODS method;
int Max_Level, level;
float alpha;
// This part must be updated if a new algorithm is added.
printf("1--> Breast-First Search
");
printf("2--> Uniform-Cost Search
");
printf("3--> Depth-First Search
");
printf("4--> Depth-Limited Search
");
printf("5--> Iterative Deepening Search
");
printf("6--> Greedy Search
");
printf("7--> A* Search
");
printf("8--> Generalized A* Search
");
printf("Select a method to solve the problem: ");
scanf("%d", &method);
if(method==DepthLimitedSearch){
printf("Enter maximum level for depth-limited search : ");
scanf("%d", &Max_Level);
}
if(method==GeneralizedAStarSearch){
printf("Enter value of alpha for Generalized A* Search : ");
scanf("%f", &alpha);
}
// Creating the root node ...
root.parent = NULL;
root.path_cost =0;
root.action = NO_ACTION; // The program will not use this part. (NO_ACTION-->0)
root.Number_of_Child =0;
printf("======== SELECTION OF INITIAL STATE ===============
");
root.state =*(Create_State());
if(PREDETERMINED_GOAL_STATE)// User will determine the goal state if it is true
{
printf("======== SELECTION OF GOAL STATE ===============
");
goal_state = Create_State();
}
if(method==GreedySearch || method==AStarSearch || method==GeneralizedAStarSearch){
root.state.h_n = Compute_Heuristic_Function(&(root.state), goal_state);
if(PREDETERMINED_GOAL_STATE)
goal_state->h_n =0;
}
switch(method)
{
case BreastFirstSearch:
case GreedySearch:
goal = First_GoalTest_Search_TREE(method, &root, goal_state); break;
case DepthFirstSearch:
case DepthLimitedSearch:
goal = DepthType_Search_TREE(method, &root, goal_state, Max_Level); break;
case IterativeDeepeningSearch:
for(level=0; TRUE ;level++){
goal = DepthType_Search_TREE(method, &root, goal_state, level);
if(goal!=FAILURE){
printf("The goal is found in level %d.
", level);
break;
}
}
break;
case UniformCostSearch:
case AStarSearch:
case GeneralizedAStarSearch:
goal = First_InsertFrontier_Search_TREE(method, &root, goal_state, alpha); break;
default:
printf("ERROR: Unknown method.
");
exit(-1);
}
Show_Solution_Path(goal);
return 0;
} change this code for 8 puzzle game

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions