Computer science assignment, please use C++ and Opencv to finish it


For this attributement, you shortness to instrument two divergent pursuit algorithms to reresolve a conundrum total. For this conundrum frolic, the GUI (graphical user interface) framework is supposing that is is patent clear by C++ and OpenCV library. The technical details are vivid in the cause files of the plan. Below is a highlight of the construction.

How to play:

After you run the plan, you should be conducive to see a conundrum frolic hence out. You can use your mouse to selecteded one share of sub-picture by one click and propel it to the utter area by clicking the utter area. At any spell, you can hit "s" key to pursuit a solution, which you shortness to instrument. 

Classes Involved:

1. VisualDisplay - This collocate deals after a while all the graphical or visual nonsense, including model era from an picture, user mouse/keyboard interface, ext (You do not shortness to deviate this collocate).

2. RandomGenerator - This collocate is used to propagate a stray succession of bulk (from 0-8), which are used as the subserviency of divergent shares of an picture that introduce divergent models. (You do not shortness to deviate this collocate).

3. SolutionSearch - This is the collocate that provides a key for a dedicated conundrum. The key can be endow by divergent pursuit algorithms. (You are required to instrument the employments in this collocate).

Requirements:

You shortness to instrument the a employments in the “SolutionSearch.cpp” file: void SolutionSearch::AStarSearch(int *data, vector<int> &solution)

(1) For the A* pursuit you shortness to conduct g(x) and h(x) for each node. (25%)

(2) For the heuristic employment h(x), you shortness to use the Manhattan Distance as the metric. (25%)

(3) Use the improve basis construction making knowing the node after a while the last f(x) = g(x) + h(x) gets large pristine (25%)

(4) Terminate the pursuit when the pristine view node is large from the remembrance (15%)

(5) Successfully confront the optimal key. (10%)

What should be acquiesceted:

You can put all your adjudication internally the employment “AStarSearch()”. But if you shortness to originate any additional basis or employments, you are suggested to put all the originated basis or employments internally the “SolutionSearch” collocate, which are considered as the members of this collocate. So you impartial shortness to acquiesce two files: “SolutionSearch.h” and “SolutionSearch.cpp” from the Isidore online plan.

Explanation of "AStarSearch()" Function:

For this function, there are two input parameters: the pristine parameter is the stray regulate of the 9 bulk, which you shortness to re-organize to form them into the improve regulate; the prevent parameter is in-fact an output. It profits or stores the melting footroad of the "void intervenience" that it is complicated to form all the sub-images in the improve posture. The integer succession variconducive "solution" should store all the steps parallel the "Optimal" footpath.

For copy: 

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

Goal:  form it into the improve regulate {0, 1, 2, 3, 4, 5, 6, 7, 8} 

You shortness to form the subjoined changes on the compute 8, past the compute 8 represents the void intervenience, melting 8 to its neighboring bulk equals to melting the similar compute to the void intervenience. Below it shows a demo of the steps: 

  0 4 1   swap after a while 4       0 8 1   swap after a while 1       0 1 8     swap after a while 2             0 1 2     swap after a while 5       0 1 2

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

  6 7 5                             6 7 5                               6 7 5                                   6 7 5                               6 7 8 

So from this copy, the exact footfootroad should be {1, 2, 5, 8}. 

WHY? You may design it was {4, 1, 2, 5}, past the compute 8 has swapped after a while them in this regulate. That is penny. However, we do not economy which compute it swapped after a while, but which posture the compute 8has bybygone through. As the bulk can be in any postures during divergent spell, which surrender no hint about where the compute 8 is. In opposition, the postures are urban. So we pretend the postures are in the identical regulate as an increasing succession: 

[0]  [1]  [2] 

   Fixed Posture =    [3]  [4]  [5] 

                                 [6]  [7]  [8]

Here, I use "[]" to characterize the postures from the bulk. So now you can see, the compute 8 starts from posture [4], then swapped after a while compute 4, which goes to the posture [1]; then swapped after a while compute 1, which goes to the posture [2]; then swapped after a while compute 2, which goes to the posture [5]; finally, swapped after a while compute 5, which goes to the posture [8]. So the footfootroad you should attribute to the parameter "&solution" after a while the footfootroad succession {1, 2, 5, 8}.