public void TC_Transitions() { var problem = new Planner.SAS.Problem(new SASInputData(GetFilePath("TC_Gripper.sas"))); ISuccessor successor = problem.GetSuccessors(problem.InitialState).First(); Assert.IsFalse(successor.IsComplexTransition()); Assert.IsTrue(successor.GetSuccessorState().Equals(successor.GetTransitionResult())); var successorResults = successor.GetComplexTransitionResults().ToList(); Assert.AreEqual(1, successorResults.Count); Assert.IsTrue(successorResults.First().Equals(successor.GetTransitionResult())); IPredecessor predecessor = problem.GetPredecessors(problem.GoalConditions).First(); Assert.IsFalse(predecessor.IsComplexTransition()); Assert.IsTrue(predecessor.GetPredecessorConditions().Equals(predecessor.GetTransitionResult())); var predecessorResults = predecessor.GetComplexTransitionResults().ToList(); Assert.AreEqual(1, predecessorResults.Count); Assert.IsTrue(predecessorResults.First().Equals(predecessor.GetTransitionResult())); IPredecessor predecessor2 = problem.GetPredecessors(problem.GoalConditions.GetCorrespondingRelativeStates(problem).First()).First(); Assert.IsTrue(predecessor2.IsComplexTransition()); Assert.IsTrue(CollectionsEquality.Equals(predecessor2.GetPredecessorRelativeStates(), predecessor2.GetComplexTransitionResults())); var predecessorResults2 = predecessor2.GetComplexTransitionResults().ToList(); Assert.AreEqual(1, predecessorResults2.Count); Assert.IsTrue(predecessorResults2.First().Equals(predecessor2.GetTransitionResult())); }
internal bool ProcessEvent(Node parentNode, ISuccessor successor) { var state = parentNode.State as IAdversarialState; var args = new StateExpansionEventArgs(state, successor, parentNode.Cost, parentNode.Depth); OnSuccessorExpanded(this, args); return !args.CancelExpansion; }
/// <summary> /// Initializes a new instance of the <see cref="StateExpansionEventArgs"/> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="successor">The successor.</param> /// <param name="cost">The cost.</param> /// <param name="depth">The depth.</param> public StateExpansionEventArgs(IState parent, ISuccessor successor, double cost, int depth) : base(parent) { Depth = depth; Cost = cost; Successor = successor; CancelExpansion = false; }
internal bool ProcessEvent(Node parentNode, ISuccessor successor) { var state = parentNode.State as IAdversarialState; var args = new StateExpansionEventArgs(state, successor, parentNode.Cost, parentNode.Depth); OnSuccessorExpanded(this, args); return(!args.CancelExpansion); }
/// <summary> /// Initializes a new instance of the <see cref="Node"/> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="successor">The successor.</param> public Node(Node parent, ISuccessor successor) { State = successor.State; Parent = parent; Successor = successor; Cost = parent.Cost + successor.Cost; Depth = parent.Depth + 1; Path = false; Children = new List <Node>(); _stateComparer = new StateComparer(); }
public Node(Node parent, ISuccessor successor) { State = successor.State; Parent = parent; Successor = successor; Cost = parent.Cost + successor.Cost; Depth = parent.Depth + 1; Path = false; Children = new List<Node>(); _stateComparer = new StateComparer(); }
/// <summary> /// Constructor /// </summary> public SuccessorEnumerable(ISuccessor <TPayload> primer) { _primer = primer; }
public static IPredecessor <TPayload> Decorate(ILink <TPayload> decorated, ISuccessor <TPayload> next) => new LinkWrapper(decorated, next);
/// <summary> /// Constructor /// </summary> public SuccessorWrapper(ISuccessor <TPayload> decorated, ISuccessor <TPayload> next) { _decorated = decorated; Next = next; }
public static IDoubleChainedLink <TPayload> Decorate(ISuccessor <TPayload> decorated, ISuccessor <TPayload> next) => new SuccessorWrapper(decorated, next);
/// <inheritdoc /> public bool MoveNext() { Current = _next.Payload; _next = _next.Previous as ISuccessor <TPayload>; return(_next is null); }
private static void PrintSuccessor(ISuccessor successor) { Console.WriteLine("{0}\n{1}", successor.Action, successor.State); Console.WriteLine("{0} {1}\n--------\n", successor.State.IsTerminal, (successor.State as IAdversarialState).Utility); }
public EndLink(ISuccessor <TPayload> previous) { Previous = LinkPredecessorDecorator <TPayload> .Decorate(previous, this); }
/// <inheritdoc /> public void Reset() { Current = default; _next = _start; }
/// <summary> /// Constructor /// </summary> public SuccessorEnumerator(ISuccessor <TPayload> start) { _start = start; Reset(); }