/// <summary> /// Strong Contruction /// </summary> /// <param name="map">Map to solve</param> public SolverController(SokobanMap map) { if (map == null) throw new ArgumentNullException("map"); this.settings = new Settings(); this.state = States.NotStarted; this.map = map; debugReport = new SolverReport(); debugReport.AppendHeading(1, "SokoSolve | Solver Debug Report v{0}", ProgramVersion.VersionString); debugReport.Append("Creating Statistics"); stats = new SolverStats(this); debugReport.Append("Creating Exit Conditions"); exitConditions = new ItteratorExitConditions(); // TODO: This should be configured, perhaps via a factory pattern debugReport.Append("Creating Forward Strategy"); strategy = new SolverStrategy(this); debugReport.Append("Creating Forward Evaluator"); evaluator = new Evaluator<SolverNode>(true); debugReport.Append("Creating Reverse Strategy"); reverseStrategy = new ReverseStrategy(this); debugReport.Append("Creating Reverse Evaluator"); reverseEvaluator = new Evaluator<SolverNode>(true); }
/// <summary> /// Strong Contruction /// </summary> /// <param name="puzzleMap"></param> public SolverController(PuzzleMap puzzleMap) { this.puzzleMap = puzzleMap; debugReport = new SolverReport(); attempted = false; stats = new SolverStats(this); exitConditions = new ExitConditions(); // TODO: This should be configured, perhaps via a factory pattern strategy = new SolverStrategy(this); evaluator = new Evaluator<SolverNode>(true); }
/// <summary> /// Write a log report to the $Content/Analysis directory /// </summary> private void BuildSolverLogReport() { if (!Directory.Exists(FileManager.GetContent("$Analysis"))) return; // Build report SolverReport report = new SolverReport(); report.AppendHeadingTwo("Puzzle"); report.AppendLabel("Library", controller.PuzzleMap.Puzzle.Library.Details.Name); report.AppendLabel("LibraryID", controller.PuzzleMap.Puzzle.Library.LibraryID); report.AppendLabel("Puzzle", controller.PuzzleMap.Puzzle.Details.Name); report.AppendLabel("PuzzleID", controller.PuzzleMap.Puzzle.PuzzleID); report.AppendHeadingTwo("Solver"); report.Build(controller); // Save string filename = "SolverReport-" + controller.PuzzleMap.Puzzle.Library.LibraryID + controller.PuzzleMap.Puzzle.PuzzleID + "-" + DateTime.Now.Ticks.ToString() + ".html"; File.WriteAllText(FileManager.GetContent("$Analysis", filename), report.ToString()); }