当前位置: 首页>>代码示例>>C#>>正文


C# Problem.IsGoalState方法代码示例

本文整理汇总了C#中Problem.IsGoalState方法的典型用法代码示例。如果您正苦于以下问题:C# Problem.IsGoalState方法的具体用法?C# Problem.IsGoalState怎么用?C# Problem.IsGoalState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Problem的用法示例。


在下文中一共展示了Problem.IsGoalState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ManualSolve

        public List<Action> ManualSolve(Problem p, Domain d)
        {
            State sStart = p.GetInitialBelief().ChooseState(true);
            State sCurrent = null, sNext = null;
            Dictionary<State, Action> dMapStateToGeneratingAction = new Dictionary<State, Action>();
            dMapStateToGeneratingAction[sStart] = null;
            Dictionary<State, State> dParents = new Dictionary<State, State>();
             dParents[sStart] = null;
            int cProcessed = 0;
            List<string> lActionNames = new List<string>();

            sCurrent = sStart;
            while (!p.IsGoalState(sCurrent))
            {
                List<Action> lActions = d.GroundAllActions(sCurrent.Predicates, false);
                Debug.WriteLine("Available actions:");
                for (int i = 0; i < lActions.Count; i++)
                {
                    Debug.WriteLine(i + ") " + lActions[i].Name);
                }
                Debug.Write("Choose action number: ");
                int iAction = int.Parse(Console.ReadLine());
                Action a = lActions[iAction];
                sNext = sCurrent.Apply(a);

                foreach (Predicate pNew in sNext.Predicates)
                    if (!sCurrent.Predicates.Contains(pNew))
                        Debug.WriteLine(pNew);

                if (!dParents.Keys.Contains(sNext))
                {
                    dParents[sNext] = sCurrent;
                    dMapStateToGeneratingAction[sNext] = a;
                }

                sCurrent = sNext;

                cProcessed++;
            }
            return GeneratePlan(sCurrent, null, dParents, dMapStateToGeneratingAction);
        }
开发者ID:dorin16s,项目名称:Planning--Network-Attack,代码行数:41,代码来源:BFSSolver.cs

示例2: SolveII

 public List<Action> SolveII(Problem p, Domain d)
 {
     State sStart = p.GetInitialBelief().ChooseState(true);
     List<State> lOpenList = new List<State>();
     lOpenList.Add(sStart);
     State sCurrent = null, sNext = null;
     Dictionary<State, Action> dMapStateToGeneratingAction = new Dictionary<State, Action>();
     dMapStateToGeneratingAction[sStart] = null;
     Dictionary<State, State> dParents = new Dictionary<State, State>();
     Dictionary<State, int> dDepth = new Dictionary<State, int>();
     dDepth[sStart] = 0;
     dParents[sStart] = null;
     int cProcessed = 0;
     List<string> lActionNames = new List<string>();
     while (lOpenList.Count > 0)
     {
         sCurrent = lOpenList[0];
         lOpenList.RemoveAt(0);
         List<Action> lActions = d.GroundAllActions(sCurrent.Predicates, false);
         foreach (Action a in lActions)
         {
             sNext = sCurrent.Apply(a);
             bool bGiven = false;
             foreach (Predicate pGiven in sNext.Predicates)
             {
                 if (pGiven.Name.ToLower().Contains("given"))
                     bGiven = true;
             }
             if (!lActionNames.Contains(a.Name))
                 lActionNames.Add(a.Name);
             if (sNext != null && p.IsGoalState(sNext))
                 return GeneratePlan(sCurrent, a, dParents, dMapStateToGeneratingAction);
             if (!dParents.Keys.Contains(sNext))
             {
                 dDepth[sNext] = dDepth[sCurrent] + 1;
                 dParents[sNext] = sCurrent;
                 dMapStateToGeneratingAction[sNext] = a;
                 lOpenList.Add(sNext);
             }
         }
         cProcessed++;
         if (cProcessed % 10 == 0)
             Debug.WriteLine(cProcessed + ") " + dDepth[sCurrent] + "," + lOpenList.Count);
     }
     return null;
 }
开发者ID:dorin16s,项目名称:Planning--Network-Attack,代码行数:46,代码来源:LandmarkSolver.cs


注:本文中的Problem.IsGoalState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。