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

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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