Example #1
0
        private static void SolveEightPuzzleProblem()
        {
            var initialState = EightPuzzleState.CreateRandomState();
            var goalState    = new EightPuzzleState(new int[3, 3] {
                { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 0 }
            });
            var actionFunction  = new EightPuzzleActionFunction();
            var resultFunction  = new EightPuzzleResultFunction();
            var goalTest        = new EightPuzzleGoalTest(goalState);
            var stepCost        = new EightPuzzleStepCost();
            var heuristic       = new EightPuzzleHeuristicFunction(goalState);
            var searchAlgorithm = new AStarGraphSearch <EightPuzzleState, EightPuzzleAction>(heuristic);

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