Write a c++ program that will solve the 8-puzzle problem

Assignment Help C/C++ Programming
Reference no: EM132841976

The 8-Puzzle: Search Algorithms

Instructions

• Your task is to write a C++ program that will solve the 8-puzzle problem using a selection of search algorithms, and their variants.

• The successors of a state are to be generated in a FIXED order, namely move the blank tile: Up, Right, Down, then Left.

Words of caution: Note that if you are using a stack data structure (last in, first out) as a container for the Search Nodes, then you will have to push into the stack the Left successor first, followed by the Down, Right, then Up successors so that the Up successor would be the first to be popped out of the stack.

• An AnimateSolution() function has been provided that you can use to animate the sequence of moves (i.e. path) calculated by the algorithms. A start-up program (compiles with gcc 9.2) with a graphics library and 2 batch files for generating experiment results are available for downloading from stream.

• It is up to you to write any functions, classes or data structures that you may require. However, for each of the algorithm, there is a specific minimum STL data structure that is required. You can use cout statements to trace the algorithms' execution.

• For each implementation of the algorithms below, include codes that will capture the following information during the algorithm's execution.

a. Max. Q length - e.g. 26
b. Path length - the number of moves to solve the puzzle, e.g. 30
c. Number of state expansions - e.g. 157
d. Actual running time in seconds (use the clock() function as shown in the start-up codes)

• Write your algorithm implementations inside the skeleton functions provided for the required algorithms. Do not change the names and input parameters of these skeleton functions as the batch files would refer to them. Each algorithm implementation should return the sequence of moves as a string. Moreover, make sure that your program runs with the supplied batch files for generating the tabulated experiment results. Your assignments will be marked using them.

e.g. string progressiveDeepeningSearch_NonStrict_VisitedList(string const initialState, string const goalState, int &numOfStateExpansions, int& maxQLength, float &actualRunningTime, int ultimateMaxDepth);
o Note that the function uses pass by reference to copy the statistical results back to the calling function

Part 1: Progressive Deepening Search (PDS)
• Use the following Search Node pushing sequence (for a Stack data structure): Left, Up,

Right, Down. Effectively, search nodes will be popped out in the following order: Up, Right, Down, Left.

a) PDS with the Visited List - in your implementation, add a facility that checks and avoids local loops
b) PDS with the Non-Strict Visited List

Part 2: Uniform Cost Search
• Use the following search node pushing sequence (for a Heap data structure): Down, Right, Up, Left
• Implement the Q container using the heap data structure implementation - available in the C++ Standard Template Library (STL): use make_heap(), push_heap(), pop_heap(), etc.

a) Without the Strict Expanded List
b) Using the Strict Expanded List

Part 3: A* Search with the Strict Expanded List
• Use the following search node pushing sequence (for a Heap data structure): Down, Right, Up, Left
• Implement the Q container using the heap data structure implementation - available in the C++ Standard Template Library (STL): use make_heap(), push_heap(), pop_heap(), etc.

c) Using the Misplaced Tiles heuristic
d) Using the Sum of Manhattan Distance heuristic

Part 4: Experiments
Test your implementation of the different algorithms by performing experiments using the 5 given (start, goal) state combinations below. Run your program until it either returns a solution, the Q becomes empty (no solution), the computer runs out of memory, or until the program crashes. Use the batch files provided to run all the experiments and collect the results easily.

Tabulate the experiment results in an Excel worksheet (convert the output of the batch file into a worksheet). Please check if the format of your tabulation of results matches the template provided (see template.xlsx). Use your surname_forename.xlsx as the name of your Excel file, and assign the name "results" to the sheet name containing the experiment results. For a group submission, just use one of the member's name.

If there is no solution found for a given (start, goal states), simply leave that section blank in the table, or write 0 in each of the required statistical measure (e.g. path length, no. of state expansions, max q length, running time, etc.).

Specify under the "comments" section of the tabulation of results if any of the following was observed for a given (start, goal state) combination:
• the program ran out of memory
• program crashed without any warning
• the Q turned empty; thus, allowing the program to close properly

BONUS
» 1 Bonus mark will be given to an original implementation and correct usage of a hash function, to speed up search. The hash value returned must be of numeric type, and there should be an

evidence of search speed increase.

(Start, Goal) State Combinations
Note: 0 - blank space

GOAL STATE: ((1 2 3)
(4 5 6)
(7 8 0))

Run the different algorithms on the following START STATES: 1. 608435127
2. 743286051
3. 647850321
4. 185024367
5. 867254301

Hints:
You can step through the search by including a getch() function (made available via the graphics engine provided in the start-up codes) inside your main loop to pause the program until the user presses any key.

Attachment:- Search Algorithms.rar

Reference no: EM132841976

Questions Cloud

Effectiveness of knowledge management efforts : What are the main strengths and weaknesses of each of the competitive strategies: home replication, multi-domestic, regional, global, and transnational?
How your initiative can reduce waste at health care setting : Identify and read two to three articles that discuss how your initiative can reduce waste at the health care setting you selected. (Nursing home)
How much of the joint cost of each production run : How much of the joint cost of each production run is allocated to Silken Skin using a net realizable value method
What exactly were the secret treaties with california indian : What exactly were the "Secret Treaties with California's Indians" discussed in Miller's article? What part(s) of the article stood out to you?
Write a c++ program that will solve the 8-puzzle problem : Write a C++ program that will solve the 8-puzzle problem using a selection of search algorithms, and their variants.
Differences between capabilities and competencies : Please describe the differences between capabilities and competencies? How are capabilities related to both resources and competencies?
How are you doing professionally and personally : This discussion will allow you an opportunity to share your thoughts and experiences of managing COVID-19 both professionally and personally as you examine.
Pestle approach to discuss businesses and organizations : For this forum assignment, you will need to locate information about a company or organization that has been in the news in the past week.
Calculate the unadjusted rate of return : Annual before-tax net cash inflow from the machine is expected to be $7,000. Calculate the unadjusted rate of return. The income tax rate is 40%

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a c program generates a ordered sequence of random num

Write a C program Gen.c that generates a ordered sequence of 20 random numbers within a range of 1000 to 9999. The program is invoked by a command line % gen datfile1

  Three or more dimensions

What kind of program, or problem, might necessitate arrays of three or more dimensions?

  Explain the steps for building a rudimentary management

Explain the steps for building a rudimentary management system.

  Program that stores a series of numbers in a binary tree

Write a program that stores a series of numbers in a binary tree

  Write a function with the heading function range

Write a function with the heading: function Range ( var a : intarray ; n : natural ): natural whose value is that of the range of the elements of the array a , that is, the difference between the maximum and minimum elements.

  Write a c program that reads in two sets of numbers a and b

Write a C program that reads in two sets of numbers A and B, and calculates and print their union (AυB) and intersection (A∩B). (AυB) is the set of elements that appear in either A or B, and thatA∩B is the set of elements that appear in both A and B...

  50 element array of integers with random numbers

write a java code to instantiate and initialize a 50 element array of integers with random numbers in the range of 45 through 256 inclusive.

  Prepare a linux shell in other words write a cc program

prepare a linux shell in other words write a cc program that will recursively prompt for input from the user. the shell

  Reads a line of characters from the user

Write a segment of code (not an entire program) that reads a line of characters from the user and outputs "too long" if the user enters more than 5 characters (not counting hitting the enter/return key).

  An evaluation of blogger

*An evaluation of Blogger *Identify and discuss the online blogs you examined and their usefulness Discuss the place blogging holds in today's availability of information, *and its advantages/disadvantages over more traditional formats such as newspa..

  Explain the importance of pointers

Assuming an array has to be sorted, inserting a new element required shifting, in the worst case, n elements, where n is the number of elements in the array, i.e.:

  We can combine assignment statements

We can combine assignment statements, for-loops, and if statements to perform a wide range of tasks with lists. Suppose we have a bookstore with each book defined as follows: Book = namedtuple('Book', 'author title genre year price instock') , wher..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd