當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。