Question: Write C program to solve the 15-puzzle problem using the A* search algorithm . In the assignment, solving a 15-puzzle problem needs to move the

Write C program to solve the 15-puzzle problem using the A* search algorithm .

In the assignment, solving a 15-puzzle problem needs to move the tiles to their goal locations, which are as shown below. The numbers 1~15 are indexes of the tiles, and 0 means blank tile. This state is the goal state.

Your program can solve the problem using a single thread or using 4 threads, depending on the first argument (argv[1]). The program uses a single thread if argv[1] is "-s", or 4 threads if argv[1] is "-m". The initial layout of the tiles is also provided in the command line as arguments by listing tile indexes in a row-major order. For example, the command ./your_program -s 2 3 0 4 1 6 7 8 5 9 10 12 13 14 11 15 is to use one thread to solve the 15-puzzle problem, in which the tiles are initially placed as follows, and are to be moved to their goal locations.

The command ./your_program -m 2 3 0 4 1 6 7 8 5 9 10 12 13 14 11 15 is to solve the above problem using 4 threads.

The execution of the program will print out the state transitions from the initial state to the goal state as a solution.

The program should run with a command line including the single/multiple-thread option (-s or -m) and 16 unique integers between 0 and15 (including 0 and 15) as tile indexes. The tile indexes are separated by spaces. ./your_program -s|-m index0 index1 index15

Your program needs to print out a sequence of states showing the movement the tiles, or text "no solution" if a solution cannot be found.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!