private static void DieHardWithAVengeance(IterativeDeepeningSolver solver) { Console.WriteLine("Die Hard with a Vengeance"); var builder = new BucketPuzzleBuilder() .CanEmpty(true) .CanRefill(true) .AddEmptyBucket(5) .AddEmptyBucket(3); var problem = builder.Build(4); var solution = solver.Solve(problem); DisplaySolution(solution); }
private static void TonyProblemWithoutFilling(IterativeDeepeningSolver solver) { Console.WriteLine("Tony Brain Teaser"); var builder = new BucketPuzzleBuilder() .CanEmpty(false) .CanRefill(false) .AddFullBucket(12) .AddEmptyBucket(8) .AddEmptyBucket(5); var problem = builder.Build(6); var solution = solver.Solve(problem); DisplaySolution(solution); }
public void Already_Solved_Puzzle_Can_Be_Solved() { // Arrange var problem = new BucketPuzzleBuilder() .AddFullBucket(5) .AddEmptyBucket(3) .CanRefill(true) .CanEmpty(true) .Build(5); var solver = new IterativeDeepeningSolver(); // Act var solveOutcome = solver.Solve(problem); // Assert solveOutcome.Classification.Should().Be(SolutionOutcomeClassification.Solution); solveOutcome.Problem.Should().BeSameAs(problem); }
public void Die_Hard_with_a_Vengeance_Puzzle_Can_Be_Solved() { // Arrange var problem = new BucketPuzzleBuilder() .AddEmptyBucket(5) .AddEmptyBucket(3) .CanRefill(true) .CanEmpty(true) .Build(4); var solver = new IterativeDeepeningSolver(); // Act var solveOutcome = solver.Solve(problem); // Assert solveOutcome.Classification.Should().Be(SolutionOutcomeClassification.Solution); solveOutcome.RootProblem.Should().BeSameAs(problem); }
public void Impossible_Scenario_Cant_Be_Solved() { // Arrange var problem = new BucketPuzzleBuilder() .AddEmptyBucket(2) .AddEmptyBucket(4) .CanRefill(true) .CanEmpty(true) .Build(1); var solver = new IterativeDeepeningSolver(); // Act var solveOutcome = solver.Solve(problem); // Assert solveOutcome.Classification.Should().Be(SolutionOutcomeClassification.CutOff); solveOutcome.RootProblem.Should().BeSameAs(problem); }
public void Tonys_Puzzle_Can_Be_Solved_Strictly() { // Arrange var problem = new BucketPuzzleBuilder() .AddFullBucket(12) .AddEmptyBucket(8) .AddEmptyBucket(5) .CanRefill(false) .CanEmpty(false) .Build(6); var solver = new IterativeDeepeningSolver(); // Act var solveOutcome = solver.Solve(problem); // Assert solveOutcome.Classification.Should().Be(SolutionOutcomeClassification.Solution); solveOutcome.RootProblem.Should().BeSameAs(problem); }