public void Traverse_35_TwoStepStrategy_FindPath() { var sb = new StringBuilder(); var writer = new StringWriter(sb); var board = new Board(writer); var strategy = new BestPosition2StepStrategy(board, FigureStep.KnightSteps); var solver = new KnightPath(board, FigureStep.KnightSteps, strategy); var path = solver.Traverse(3, 5); for (int i = 0; i < path.Count; ++i) { _output.WriteLine($"{i}: {path[i].r} {path[i].c}"); } _output.WriteLine(sb.ToString()); board.ContainUnvisitedCells().Should().BeFalse(); }
public void Traverse_AllStartPositions_FindPathEachTime() { for (int i = 0; i < Board.Size; i++) { for (int j = 0; j < Board.Size; j++) { if (i == 3 && j == 5) { continue; } var board = new Board(null); var strategy = new BestPositionStrategy(board, FigureStep.KnightSteps); var solver = new KnightPath(board, FigureStep.KnightSteps, strategy); var path = solver.Traverse(i, j); _output.WriteLine($"start position {i}, {j}"); board.ContainUnvisitedCells().Should().BeFalse(); _output.WriteLine("is ok"); } } }
static void testKnightPath() { KnightPath kp = new KnightPath(6); kp.solve(); }