protected AbstractNode(AbstractState state, AbstractState target, AbstractNode Parent, AbstractAction action) { this.State = state; this.Target = target; this.Parent = Parent; this.Action = action; }
public RouteFindingNode(AbstractNode parent, AbstractAction action, RouteFindingState state, RouteFindingState target) : base(state, target, parent, action) { if (this.Parent != null && this.Action != null) this.PathCost = this.Parent.PathCost + action.Cost; this.EstimatedTotalPathCost = this.PathCost + Math.Sqrt(Math.Pow(state.X - target.X, 2) + Math.Pow(state.Y - target.Y, 2)); }
public InferenceNode(AbstractNode parent, AbstractState target, AbstractState state, AbstractAction action) : base(state, target, parent, action) { this.PathCost = this.Parent.PathCost + 1; this.EstimatedTotalPathCost = this.State.Clause.Count; }
public AbstractNode Resolve(AbstractNode parent, AbstractAction action, AbstractState targetState) { return new RouteFindingNode(parent, action, action.EndState as RouteFindingState, targetState as RouteFindingState); }
public AbstractNode Resolve(AbstractNode parent, AbstractAction action, AbstractState targetState) { return this.ApplyResolution(parent as InferenceNode, action); }
public InferenceNode ApplyResolution(InferenceNode parent, AbstractAction act) { var state = new InferenceState(); var actionState = act.StartState as InferenceState; foreach (var firstLiteral in parent.State.Clause) { foreach (var secondLiteral in actionState.Clause) { if (firstLiteral.Name.Equals(secondLiteral.Name) && firstLiteral.Proposition != secondLiteral.Proposition) { // Merger samtlige literals fra de to clauses state.Clause = parent.State.Clause.Concat(actionState.Clause).ToList(); // Fjern en enkelt positiv og en enkelt negativ state.Clause.Remove(state.Clause.First(lit => lit.Name.Equals(secondLiteral.Name) && lit.Proposition)); state.Clause.Remove(state.Clause.First(lit => lit.Name.Equals(secondLiteral.Name) && !lit.Proposition)); // Fjerne duplikater, f.eks. A & A & B -> A & B state.Clause = state.Clause.Distinct().ToList(); return new InferenceNode(parent, parent.Target, state, new InferenceAction(state, parent.Target)); } } } //Fjerner resten af modsatte literals.. return new InferenceNode(parent, parent.Target, state, new InferenceAction(state, parent.Target)); }