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; }
public virtual bool Find(IState initialState) { if (Strategy == null) return false; Strategy.Add(new Node(initialState)); while (Strategy.Count() > 0) { var n = Strategy.Remove(); if (n.Parent != null && n.Successor != null) { var eventArgs = new StateExpansionEventArgs(n.Parent.State, n.Successor, n.Cost, n.Depth); OnSuccessorExpanded(this, eventArgs); if (eventArgs.CancelExpansion) return false; } if (n.State.IsTerminal) { CreateSolution(n); return true; } foreach (var node in n.Expand(_closed)) { Strategy.Add(node); if (_closed != null) _closed.Add(node.State); } } return 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); }
protected virtual void OnSuccessorExpanded(object sender, StateExpansionEventArgs e) { EventHandler <StateExpansionEventArgs> handler = SuccessorExpanded; if (handler != null) { handler(sender, e); } }
public virtual bool Find(IState initialState) { if (Strategy == null) { return(false); } Strategy.Add(new Node(initialState)); while (Strategy.Count() > 0) { var n = Strategy.Remove(); if (n.Parent != null && n.Successor != null) { var eventArgs = new StateExpansionEventArgs(n.Parent.State, n.Successor, n.Cost, n.Depth); OnSuccessorExpanded(this, eventArgs); if (eventArgs.CancelExpansion) { return(false); } } if (n.State.IsTerminal) { CreateSolution(n); return(true); } foreach (var node in n.Expand(_closed)) { Strategy.Add(node); if (_closed != null) { _closed.Add(node.State); } } } return(false); }
protected virtual void OnSuccessorExpanded(object sender, StateExpansionEventArgs e) { EventHandler<StateExpansionEventArgs> handler = SuccessorExpanded; if (handler != null) handler(sender, e); }