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


C# PrologContext.MarkTrail方法代码示例

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


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

示例1: TestClausesInOrder

 /// <summary>
 /// Tests clauses in the order they appear in the database.
 /// </summary>
 IEnumerable<CutState> TestClausesInOrder(object[] args, PrologContext context, ushort myFrame)
 {
     var mark = context.MarkTrail();
     var argIndexers = PredicateArgumentIndexer.ArglistIndexers(args);
     entriesListUsed = true;
     foreach (var entry in Entries)
     {
         if (entry.Prematch(argIndexers))
         {
             context.SetCurrentRule(entry);
             foreach (var cutState in entry.Prove(args, context, myFrame))
             {
                 if (cutState == CutState.ForceFail)
                 {
                     if (KnowledgeBase.Trace || Trace)
                         context.TraceOutput("Cut: {0}", new Structure(Name, args));
                     goto fail;
                 }
                 if (KnowledgeBase.Trace || Trace)
                     context.TraceOutput("Succeed: {0}", new Structure(Name, args));
                 yield return CutState.Continue;
                 if (KnowledgeBase.Trace || Trace)
                     context.TraceOutput("Retry: {0}", new Structure(Name, args));
             }
         }
     }
     fail:
     context.RestoreVariables(mark);
     if (KnowledgeBase.Trace || Trace)
         context.TraceOutput("Fail: {0}", new Structure(Name, args));
     //context.UnwindStack(Name, args);
     context.UnwindStack(myFrame);
 }
开发者ID:ianhorswill,项目名称:UnityProlog,代码行数:36,代码来源:PredicateInfo.cs

示例2: TestShuffledClauses

 /// <summary>
 /// Tests clauses in a randomized order (but still exhaustively).
 /// Uses Shuffler to generate a random permutation.
 /// </summary>
 IEnumerable<CutState> TestShuffledClauses(object[] args, PrologContext context, ushort myFrame)
 {
     entriesListUsed = true;
     var mark = context.MarkTrail();
     var shuffler = new Shuffler((ushort)Entries.Count);
     var argIndexers = PredicateArgumentIndexer.ArglistIndexers(args);
     while (!shuffler.Done)
     {
         var entry = Entries[shuffler.Next()];
         if (entry.Prematch(argIndexers))
         {
             // This shouldn't be here...
             //context.PushGoalStack(Name, args, myFrame);
             context.SetCurrentRule(entry);
             foreach (var cutState in entry.Prove(args, context, myFrame))
             {
                 if (cutState == CutState.ForceFail)
                 {
                     if (KnowledgeBase.Trace || Trace)
                         context.TraceOutput("Cut: {0}", new Structure(Name, args));
                     goto fail;
                 }
                 if (KnowledgeBase.Trace || Trace)
                     context.TraceOutput("Succeed: {0}", new Structure(Name, args));
                 yield return CutState.Continue;
                 if (KnowledgeBase.Trace || Trace)
                     context.TraceOutput("Retry: {0}", new Structure(Name, args));
             }
         }
     }
     fail:
     context.RestoreVariables(mark);
     if (KnowledgeBase.Trace || Trace)
         context.TraceOutput("Fail: {0}", new Structure(Name, args));
     //context.UnwindStack(Name, args);
     context.UnwindStack(myFrame);
 }
开发者ID:ianhorswill,项目名称:UnityProlog,代码行数:41,代码来源:PredicateInfo.cs

示例3: UnifyArraysFast

 internal static IEnumerable<bool> UnifyArraysFast(object[] a1, object[] a2, PrologContext context)
 {
     int mark = context.MarkTrail();
     if (UnifyArrays(a1, a2, context))
         yield return false;
     context.RestoreVariables(mark);
 }
开发者ID:ianhorswill,项目名称:UnityProlog,代码行数:7,代码来源:Term.cs


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