Solver - import java.util.ArrayList import...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.Queue; import java.util.Stack; public class Solver { private InputSource initial; private InputSource goal; private tray blockPools; private pattern solution; private tray goalPools; private int Row; private int Col; private boolean equalNumOfBlocks; private PatternPools visited; //Para: two String file of the initial Configuration and the goal configuration //Constructor of Solver, initialize all the private instance variable public Solver(String iniConfigFile, String goalConfigFile){ initial=new InputSource(iniConfigFile); goal=new InputSource(goalConfigFile); String size=initial.readLine(); String trayinfo=size.split(" "); int r=Integer.parseInt(trayinfo[0]); int c=Integer.parseInt(trayinfo[1]); Row=r; Col=c; blockPools=new tray(); goalPools=new tray(); solution=null; visited=new PatternPools(); equalNumOfBlocks=false; } //initialize the every block's information public void init(){ int width; int length; int row; int col; int prev_width=-1; int prev_length=-1; int block_value; block b; String tempBlock=initial.readLine(); String blockinfo; int ini_count=0; int goal_count=0; while(tempBlock!=null){ blockinfo=tempBlock.split(" "); length=Integer.parseInt(blockinfo[0]); width=Integer.parseInt(blockinfo[1]); row=Integer.parseInt(blockinfo[2]); col=Integer.parseInt(blockinfo[3]); block_value=((length<<24)|(width<<16)|(row<<8)|col); b=new block(block_value); blockPools.add(b); ini_count++; prev_length=length; prev_width=width; tempBlock=initial.readLine(); } tempBlock=goal.readLine(); while(tempBlock!=null){ blockinfo=tempBlock.split(" "); length=Integer.parseInt(blockinfo[0]); width=Integer.parseInt(blockinfo[1]); row=Integer.parseInt(blockinfo[2]); col=Integer.parseInt(blockinfo[3]); block_value=((length<<24)|(width<<16)|(row<<8)|col);...
View Full Document

{[ snackBarMessage ]}

Page1 / 7

Solver - import java.util.ArrayList import...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online