Exemple #1
0
        public static double ComputeHeuristic(AStar.IState state, AStar.IState goalState)
        {
            if (state.CompareTo(goalState) == 0)
            {
                return(0);
            }
            var st = state as State;

            return(st.Node.Heuristic);
        }
Exemple #2
0
        public IEnumerable <Tuple <AStar.IState, AStar.IAction, double> > Expand(AStar.IState state)
        {
            var st             = state as State;
            var expandedStates = new List <Tuple <AStar.IState, AStar.IAction, double> >();

            if (st.Node.Left != null)
            {
                var cState = new State();
                cState.Cache = st.Cache.Clone();
                cState.Node  = st.Node.Left;
                expandedStates.Add(new Tuple <AStar.IState, AStar.IAction, double>(cState, new Action("Left"), ComputeCost(cState)));
            }
            if (st.Node.Right != null)
            {
                var cState = new State();
                cState.Cache = st.Cache.Clone();
                cState.Node  = st.Node.Right;
                expandedStates.Add(new Tuple <AStar.IState, AStar.IAction, double>(cState, new Action("Right"), ComputeCost(cState)));
            }
            return(expandedStates);
        }
Exemple #3
0
 public bool IsGoal(AStar.IState state, AStar.IState goal)
 {
     return(state.CompareTo(goal) == 0);
 }