public HSPNode(HashSet <string> state, HSPAction action, HSPNode parent = null, int g = 0, int h = 0) { _state = state; _action = action; _parent = parent; _g = g; _h = h; _stateString = setStateString(); }
public List <HSPAction> BeginDeriveActions(List <HSPOperator> _operations, List <HSPPredicate> _objects) { List <HSPAction> actions = new List <HSPAction>(); foreach (HSPOperator _operator in _operations) { List <string> variables = new List <string>(); variables = DeriveVariables(_operator); List <HashSet <string> > objects = new List <HashSet <string> >(); objects = DeriveObjects(_operator, _objects); List <List <string> > product = new List <List <string> >(); product = CartesianProduct(objects); foreach (var prod in product) { Dictionary <string, string> subst = new Dictionary <string, string>(); //'Replaces' Zip... for (var i = 0; i < variables.Count; i++) { subst.Add(variables[i], prod[i]); } bool valid = true; foreach (HSPLiteral _precondition in _operator._preconditions) { if (_precondition.isNegative()) { string lhs = prod[0]; string rhs = prod[1]; if (lhs == rhs) { valid = false; break; } } } if (valid) { HSPAction action = ConvertOperatorIntoAction(_operator, subst); actions.Add(action); } } } return(actions); }
private HashSet <string> DeriveNewStateFromAction(HSPAction action, HashSet <string> groundedState) { Stopwatch watch = new Stopwatch(); watch.Start(); //Derive New State From Action HashSet <string> newGrounds = new HashSet <string>(); foreach (var item in groundedState) { newGrounds.Add(item); } newGrounds.ExceptWith(action.getNegEffects()); newGrounds.UnionWith(action.getPosEffects()); watch.Stop(); timeDeriveState += watch.Elapsed.TotalSeconds; return(newGrounds); }