Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
13 views

Instructions For This Assignment You Need To Implement Two Different Search Algorithms To Solve

This document provides instructions for an assignment to implement two search algorithms, breadth-first and depth-first, to solve a puzzle game. Students are given a GUI framework and must write code for the SolutionSearch class to return the optimal path using each algorithm. The class structure and requirements are outlined.

Uploaded by

Charlotte
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Instructions For This Assignment You Need To Implement Two Different Search Algorithms To Solve

This document provides instructions for an assignment to implement two search algorithms, breadth-first and depth-first, to solve a puzzle game. Students are given a GUI framework and must write code for the SolutionSearch class to return the optimal path using each algorithm. The class structure and requirements are outlined.

Uploaded by

Charlotte
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Instructions For this assignment, you need to implement

two different search algorithms to solve...

Instructions

For this assignment, you need to implement two different search algorithms to solve a puzzle
problem. For this puzzle game, the GUI (graphical user interface) framework is provided that is
is dev
GET THE ANSWER>> https://solutionlly.com/downloads/instructions-for-this-assignment-you-
need-to-implement-two-different-search-algorithms-to-solve

Instructions

For this assignment, you need to implement two different search algorithms to solve a puzzle
problem. For this puzzle game, the GUI (graphical user interface) framework is provided that is
is developed by C++ and OpenCV library. The technical details are described in the source files
of the project. Below is a highlight of the structure.

How to play:

After you run the project, you should be able to see a puzzle game coming out. You can use
your mouse to select one piece of sub-image by one click and move it to the blank area by
clicking the blank area. At any time, you can hit "s" key to search a solution, which you need to
implement.

Classes Involved:
1.VisualDisplay- This class deals with all the graphical or visual stuff, including pattern
generation from

an image, user mouse/keyboard interface, ext (You do not need to modify this class).

2.RandomGenerator- This class is used to generate a random sequence of numbers (from 0-8),
which are used as the orders of different pieces of an image that present different patterns.
(You do not need to modify this class).

3.SolutionSearch- This is the class that provides a solution for a given puzzle. The solution can
be found by different search algorithms. (You are required to implement the functions in this
class).

Requirements:
1/3
You need to implement the two functions in the “SolutionSearch.cpp” file:

1.

breadthSearch(int *data, vector &solution) (50%)

2.

depthSearch(int *data, vector &solution) (50%).

What should be submitted:

You can put all your code inside the two functions “breathSearch()” and “depthSearch()”. But if
you want to create any additional data or functions, you are suggested to put all the created
data or functions inside the “SolutionSearch” class, which are considered as the members of
this class. So you just need to submit two files: “SolutionSearch.h” and “SolutionSearch.cpp”
from the Isidore online system.

Explanation of A Search Function:

For each search function, there are two input parameters: the first parameter is the random
order of the 9 numbers, which you need to re-organize to make them into the correct order; the
second parameter is actually an output. It returns or stores the moving path of the "empty
space" that it is involved to make all the sub-images in the correct position. The integer
sequence variable "solution" should store all the steps along the "Optimal" path.

For example:
Input: data={0,4,1,3,8,2,6,7,5};

Goal: make it into the correct order {0, 1, 2, 3, 4, 5, 6, 7, 8}

You need to make the following changes on the number 8, since the number 8 represents the
empty space, moving 8 to its neighboring numbers equals to moving the corresponding number
to the empty space. Below it shows a demo of the steps:

0 4 1swap with 40 8 1swap with 10 1 8swap with 20 1 2swap with 50 1 2


3 8 2 -----------------> 3 4 2 -----------------> 3 4 2 -----------------> 3 4 8 ------------------> 3 4 5 --

----------> End
675 675 675 675 678

So from this example, the right path should be {1, 2, 5, 8}.

WHY? You may thought it was {4, 1, 2, 5}, since the number 8 has swapped with them in this
order. That is true. However, we do not care which number it swapped with, but which position
the number 8has gone through. As the numbers can be in any positions during different time,
which give no hint about where the number 8 is. In contrast, the positions are fixed. So we
assume the positions are in the same order as an increasing sequence:
2/3
[0] [1] [2] Fixed Position =[3] [4] [5] [6] [7] [8]

Here, I use "[]" to distinguish the positions from the numbers. So now you can see, the number
8
starts from position [4], then swapped with number 4, which goes to the position [1]; then
swapped with number 1, which goes to the position [2]; then swapped with number 2, which
goes to the position [5]; finally, swapped with number 5, which goes to the position [8]. So the
path you should assign to the parameter "&solution" with the path sequence {1, 2, 5, 8}.

Instructions For this assignment, you need to implement two different search algorithms to
solve...
GET THE ANSWER>> https://solutionlly.com/downloads/instructions-for-this-assignment-you-
need-to-implement-two-different-search-algorithms-to-solve

3/3
Powered by TCPDF (www.tcpdf.org)

You might also like