Chat with us, powered by LiveChat Complete the puzzle method by using heuristic search f(n) = g(n)+ h(n).For h(n) use sum of distances out of place (hamilton distance).Make sure to write your name in main method.3- Create an | Wridemy

Complete the puzzle method by using heuristic search f(n) = g(n)+ h(n).For h(n) use sum of distances out of place (hamilton distance).Make sure to write your name in main method.3- Create an

2- Complete the puzzle method by using heuristic search f(n) = g(n)+ h(n).

For h(n) use sum of distances out of place (hamilton distance).
Make sure to write your name in main method.
3- Create an input file as follow:
3
1 3 2 5 0 4 8 7 6               1 3 2 5 7 4 8  6  0
1 5 2 0 8 6 3 7 4               1 2 3 4 5 0 8  7  6 
1 3 2 5 0 4 8 7 6               0 1 3 2 5 7 4  6  8
4- For each input print:
Initial state, Goal Sate, the no. of moves as well as moves from initial state to goal
state. for example:
Initial state: 1 3 2 5 0 4 8 7 6,
Goal State:  1 3 2 5 7 4 8  6  0,  
10 moves: L, R, D, ……..
*private void puzzle(int cs[], int gs[]){ //complete this method, on attached file.

import java.io.*; import java.util.*; // 8 puzzle program public class xxxxx8puz { //class variables //use prt for System.out to save typing PrintStream prt = System.out; //Print Graph Matrix private void prtStates(int cur[], int nxt[], String mov){ int j, k, m, n; // Print Graph matrix prt.printf("ntFrom cur state to nxt state using %s move:nt", mov); for (j = 0; j < 3; j++){ m = j * 3; n = m + 3; for (k = m; k < n; k++) prt.printf("%3d", cur[k]); //end for k =m prt.printf("t"); for (k = m; k < n; k++) prt.printf("%3d", nxt[k]); //end for k =m prt.printf("nt"); } //end for j =1 } // end prtStates // 8-puuzle from current sate to goal state private void puzzle(int cs[], int gs[]){ //complete this method } // end puzzle private void process(String fn) { // read input int cs[], gs[]; //initial and goal state int i, j, n; long start, end; prt.printf("nt8 Puzzle program:"+ "ntThis method reads initial state and goal state from inputfile"+ "ntand prints all the moves from initial state to goal state."+ "nttTo compile: javac xxxxx8puz.java" + "nttTo execute: java xxxxx8puz inputfilename"+ "ntt Example: java xxxxx8puz inputfilename"); //Allocate space for initial and goal states cs = new int[9]; gs = new int[9]; try{ // open input file Scanner inf = new Scanner(new File(fn)); n = inf.nextInt();//read no. of cases // read initial and goal states for (i = 1; i <= n; i++){ // read current state for (j = 0; j <= 8; j++) cs[j]= inf.nextInt(); // end for j // read goal state for (j = 0; j <= 8; j++) gs[j]= inf.nextInt(); // end for j //initial state and goal state prtStates(cs, gs, "??"); //Get System Time start = System.currentTimeMillis(); puzzle(cs, gs); //Get System Time end = System.currentTimeMillis(); prt.printf("ntExec Time: %d ms", end – start); } // end for i // close input file inf.close(); }catch(IOException e) {prt.printf("nI/O Error %s", e );} } // end process method public static void main(String[] args) throws Exception{ int cnt = args.length; // get no. of arguments String fn; if (cnt < 1){ System.out.printf("ntOOOPS Invalid No. of aguments!"+ "ntTO Execute: java xxxxx8puz inputfilename"); return; } // end if // get input file name fn = args[0]; // create an instance of xxxxx8puz class xxxxx8puz g = new xxxxx8puz (); // call process method g.process(fn); //Replace ????????? with your name in next line System.out.printf("nntAuthor: ????????? Date: %sn", java.time.LocalDate.now()); } // end main } // end xxxxx8puz /*Sample 8-puzzle input 3 1 3 2 5 0 4 8 7 6 1 3 2 5 7 4 8 6 0 1 5 2 0 8 6 3 7 4 1 2 3 4 5 0 8 7 6 1 3 2 5 0 4 8 7 6 0 1 3 2 5 7 4 6 8 */

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

About Wridemy

We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

How It Works

To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Are there Discounts?

All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

Hire a tutor today CLICK HERE to make your first order

Related Tags

Academic APA Writing College Course Discussion Management English Finance General Graduate History Information Justify Literature MLA