/** Create a solver instance and configures it with initial and goal state. */ private void constructPuzzleSolver() { pSolver = null; // this is the call to the actual implementation of PuzzleSolver if ("DFS".equals(solver)) pSolver = new DFSSolver(); if ("BFS".equals(solver)) pSolver = new BFSSolver(); if ("ASTAR".equals(solver)) pSolver = new AStarSolver(); if (null == pSolver) // default case, make sure we have a solver pSolver = new BFSSolver(); pSolver.configure(initalPuzzleGraphics.getPuzzle(), finalPuzzleGraphics.getPuzzle()); }
/** * Configures the puzzle solver by creating initial and goal states from a list of predefined * puzzles. It also draws the GUI panels after creation of puzzle states * * @param nPuzzle represents the size of the puzzle */ public void setConfiguration(final int nPuzzle) { initalPuzzleGraphics.setConfiguration(nPuzzle, PanelType.INITIALPANEL); intermediatePuzzleGraphics.setConfiguration(nPuzzle, PanelType.INTERMEDIATEPANEL); finalPuzzleGraphics.setConfiguration(nPuzzle, PanelType.GOALPANEL); initalPuzzleGraphics.repaint(); intermediatePuzzleGraphics.repaint(); finalPuzzleGraphics.repaint(); constructPuzzleSolver(); }