Inheritance: IState
Example #1
0
        public void Test_Easy_Square_BFS()
        {
            IState init = new Square(new[] { 1, 4, 2, 3, 5, 8, 6, 0, 7 });
            Console.WriteLine(init);
            var bfs = new SimpleSearch<IState, ISuccessor>(new BreadthFirstSearch());
            var solution = bfs.Find(init);

            if (solution) PrintSolution(bfs.Solution);
            Assert.True(solution);
        }
Example #2
0
        public void Test_Hard_AStar()
        {
            IState init = new Square(new[] { 1, 2, 3, 4, 5, 6, 7, 0, 8 });

            AStarSearch strategy = new AStarSearch();

            var a = new SimpleSearch<IState, ISuccessor>(strategy);
            var solution = a.Find(init);
            if (solution) PrintSolution(a.Solution);
            Assert.True(solution);
        }
Example #3
0
        public void Test_Square_Expansion()
        {
            for (int i = 0; i < 9; i++)
            {
                int[] square = CreateSquare(i);
                IState init = new Square(square);
                Console.WriteLine(init.ToString());
                foreach (var s in init.GetSuccessors())
                {
                    Console.WriteLine("---------\n{0} ({1}{2})", s.Action, s.Cost, s.State.IsTerminal ? ", Goal" : "");
                    Console.WriteLine(s.State);
                }

                Console.WriteLine("------------------------------------------");
            }
        }