Example #1
0
        public void NoSolutions()
        {
            var command = new SolverCommand
            {
                Puzzle = Puzzle.Builder.FromLines(new[]
                {
                    "##########",
                    "#O....X..#",
                    "#O..P..X.#",
                    "#O....X..#",
                    "##########"
                }),
                Report         = new XUnitOutput(outp),
                ExitConditions = ExitConditions.OneMinute()
            };

            var solver = new SingleThreadedForwardSolver(new SolverNodeFactoryTrivial());
            var state  = solver.Init(command) as SolverBaseState;
            var result = solver.Solve(state);

            Assert.Empty(state.Solutions);
            Assert.NotEmpty(state.Root.Children);

            foreach (var n in state.Root.Recurse())
            {
                outp.WriteLine(n.ToString());
            }
            Assert.Equal(4, state.Root.CountRecursive()); // NOTE: Should this not be 5 = 2 valid pushes, then 3 dead
            Assert.True(state.Root.Recurse().All(x => ((SolverNode)x).IsClosed));
            Assert.Equal(ExitConditions.Conditions.ExhaustedTree, result);
        }
        public void NoSolutions()
        {
            var command = new SolverCommand
            {
                Puzzle = Puzzle.Builder.FromLines(new[]
                {
                    "##########",
                    "#O....X..#",
                    "#O..P..X.#",
                    "#O....X..#",
                    "##########"
                }),
                Report         = TextWriter.Null,
                ExitConditions = ExitConditions.OneMinute()
            };

            var solver = new SingleThreadedForwardSolver(new SolverNodeFactoryTrivial());
            var state  = solver.Init(command) as SolverBaseState;
            var result = solver.Solve(state);

            Assert.Empty(state.Solutions);
            Assert.NotEmpty(state.Root.Children);
            Assert.Equal(2, state.Root.CountRecursive());
            Assert.True(state.Root.All(x => ((SolverNode)x).IsClosed));
            Assert.Equal(ExitConditions.Conditions.ExhaustedTree, result);
        }
Example #3
0
        public void NoSolutions_InvalidPuzzle()
        {
            var command = new SolverCommand
            {
                Puzzle = Puzzle.Builder.FromLines(new[]
                {
                    // More goals than crates - strictly not valid
                    "##########",
                    "#O...X..O#",
                    "#O..XPX.O#",
                    "#O..X.X.O#",
                    "##########"
                }),
                Report         = new XUnitOutput(outp),
                ExitConditions = ExitConditions.OneMinute()
            };

            var solver = new SingleThreadedForwardSolver(new SolverNodeFactoryTrivial());

            Assert.Throws <InvalidDataException>(() =>
            {
                var state = solver.Init(command) as SolverBaseState;
            });
        }