本文整理汇总了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);
}
示例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);
}
示例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);
}