public void FloodCrateMoveMap() { SokobanMap map = new SokobanMap(); map.setFromStrings(new string[] { "~~~###~~~~~", "~~##.#~####", "~##..###..#", "##.X......#", "#...PX.#..#", "###.X###..#", "~~#..#OO..#", "~##.##O#.##", "~#......##~", "~#.....##~~", "~#######~~~" }); Bitmap result = CrateAnalysis.BuildCrateMoveMap(map, new VectorInt(3,3)); Assert.IsNotNull(result); Debug.WriteLine(map.ToString()); Debug.WriteLine(result.ToString()); Debug.WriteLine("done."); }
protected SolverResult Solve(SokobanMap puzzle) { using (CodeTimer timer = new CodeTimer("TestSolver.Solve(...)")) { SolverController controller = new SolverController(puzzle); try { System.Console.WriteLine(puzzle.ToString()); SolverResult results = controller.Solve(); if (results.Exception != null) { // Bubble up throw new Exception("Solver Failed Iternally", results.Exception); } if (results.Status == SolverResult.CalculationResult.SolutionFound) { // Check that Assert.IsTrue(results.HasSolution, "State says a solution was found, but none are listed in solutions list"); } if (results.HasSolution) { int cc = 0; foreach (Solution solution in results.Solutions) { string testRes = "Error"; Assert.IsTrue(solution.Test(puzzle, out testRes), testRes); Console.WriteLine("Testing solution: {0} - {1}", cc, testRes); cc++; } } return results; } finally { timer.Stop(); Console.WriteLine(controller.DebugReport.ToString(new DebugReportFormatter())); System.Console.WriteLine("Total Time: " + timer.Duration(1)); System.Console.WriteLine("---"); } } }
public void TestFindCratePath() { SokobanMap map = new SokobanMap(); map.setFromStrings(new string[] { "~~~###~~~~~", "~~##.#~####", "~##..###..#", "##.X......#", "#...PX.#..#", "###.X###..#", "~~#..#OO..#", "~##.##O#.##", "~#......##~", "~#.....##~~", "~#######~~~" }); CrateAnalysis.ShortestCratePath result = CrateAnalysis.FindCratePath(map, new VectorInt(3, 3), new VectorInt(9, 5)); Assert.IsNotNull(result); Debug.WriteLine(map.ToString()); Debug.WriteLine(result.CratePath.ToString()); Debug.WriteLine(result.PlayerPath.ToString()); Debug.WriteLine("done."); }