Exemple #1
0
        private static void SolveSudokuProblem()
        {
            var initialState =
                new SudokuState(
                    new int[9, 9]
            {
                { 0, 0, 5, 0, 3, 0, 0, 6, 2 },
                { 0, 3, 0, 8, 9, 0, 0, 0, 1 },
                { 0, 2, 9, 4, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 2, 6, 0, 0, 0, 0 },
                { 8, 9, 3, 0, 0, 0, 0, 0, 0 },
                { 6, 0, 0, 0, 0, 0, 8, 5, 0 },
                { 3, 6, 8, 9, 0, 0, 0, 0, 0 },
                { 0, 0, 4, 0, 0, 0, 0, 9, 6 },
                { 0, 0, 0, 0, 4, 3, 0, 0, 0 }
            });

            var actionFunction  = new SudokuActionFunction();
            var resultFunction  = new SudokuResultFunction();
            var goalTest        = new SudokuGoalTest();
            var stepCost        = new SudokuStepCost();
            var searchAlgorithm = new GraphSearch <SudokuState, SudokuAction>();

            SolveProblem(actionFunction, resultFunction, goalTest, stepCost, initialState, searchAlgorithm);
        }
Exemple #2
0
        private static void SolveRomaniaProblem()
        {
            var actionFunction  = new TravelActionFunction();
            var resultFunction  = new TravelResultFunction();
            var goalTest        = new TravelGoalTest(TravelState.Lugoj);
            var stepCost        = new TravelStepCost();
            var intialState     = TravelState.Arad;
            var searchAlgorithm = new GraphSearch <TravelState, TravelAction>();

            SolveProblem(actionFunction, resultFunction, goalTest, stepCost, intialState, searchAlgorithm);
        }
Exemple #3
0
        private static void SolveWeblinkProblem()
        {
            var initialState    = new WeblinkState(new Uri("http://www.heise.de"));
            var goalState       = new WeblinkState(new Uri("http://www.facebook.com"));
            var actionFunction  = new WeblinkActionFunction();
            var resultFunction  = new WeblinkResultFunction();
            var goalTest        = new WeblinkGoalTest(goalState);
            var stepCost        = new WeblinkStepCost();
            var searchAlgorithm = new GraphSearch <WeblinkState, WeblinkAction>();

            SolveProblem(actionFunction, resultFunction, goalTest, stepCost, initialState, searchAlgorithm);
        }
Exemple #4
0
        private static void SolveMissionariesProblem()
        {
            var goalState       = new MissionariesState(0, 0, 0, 0, NUMBER, NUMBER, Direction.Right);
            var actionFunction  = new MissionariesActionFunction(goalState);
            var resultFunction  = new MissionariesResultFunction();
            var goalTest        = new MissionariesGoalTest(goalState);
            var stepCost        = new MissionariesStepCost();
            var initialState    = new MissionariesState(NUMBER, NUMBER, 0, 0, 0, 0, Direction.Left);
            var searchAlgorithm = new GraphSearch <MissionariesState, MissionariesAction>();

            SolveProblem(actionFunction, resultFunction, goalTest, stepCost, initialState, searchAlgorithm);
        }
Exemple #5
0
        private static void SolvePathFindingProblem()
        {
            var initialState = new PathFindingState(new Point(1, 1));
            var goalState    = new PathFindingState(new Point(5, 5));

            var environment = new PathFindingEnvironment();

            environment.PointLines.Add(new PointLine(new Point(1, 3), new Point(3, 1)));
            environment.PointLines.Add(new PointLine(new Point(3, 1), new Point(5, 3)));
            environment.PointLines.Add(new PointLine(new Point(5, 3), new Point(3, 5)));
            environment.PointLines.Add(new PointLine(new Point(3, 5), new Point(1, 3)));
            environment.PointLines.Add(new PointLine(new Point(3, 1), new Point(3, 5)));
            environment.PointLines.Add(new PointLine(new Point(1, 3), new Point(5, 3)));

            var actionFunction  = new PathFindingActionFunction(environment, goalState);
            var resultFunction  = new PathFindingResultFunction();
            var goalTest        = new PathFindingGoalTest(goalState);
            var stepCost        = new PathFindingStepCost();
            var searchAlgorithm = new GraphSearch <PathFindingState, PathFindingAction>();

            SolveProblem(actionFunction, resultFunction, goalTest, stepCost, initialState, searchAlgorithm);
        }