private void GenerateGroundActions() { //now for each action, generate all possible argument lists and then generate an id. foreach (ProblemParser.Operator op in mDC.Operators) { // now for all possible arguments: op.ComputeHash(); int argCount = op.ParamNames.Count; //TODO: Check this List <int> argList = Enumerable.Repeat(0, argCount).ToList <int>(); int maxParamLinIndex = mDC.GetMaxIndexForSize(argCount); PlanAction.ID actID = new PlanAction.ID(); actID.ActionName = op.Name; actID.ParamCount = op.ParamNames.Count; actID.DC = mDC; for (int paramLinearIndex = 0; paramLinearIndex < maxParamLinIndex; paramLinearIndex++) { mDC.GetMultiIndex(paramLinearIndex, ref argList); // now make them ground! PlanAction act = GenerateSingleGroundAction(op, argList); act.ActionID = actID; act.ParametersIndex = paramLinearIndex; Actions.Add(act); } } }
private void AddSinglePred(int pred, ref StringBuilder sb) { // Search for the right predicate candidate int pid = DC.Predicates.Count - 1; for (int i = 0; i < DC.Predicates.Count - 1; i++) { if (DC.Predicates[i].StartIndex <= pred && DC.Predicates[i + 1].StartIndex > pred) { pid = i; break; } } // assure it is a valid predicate Debug.Assert(pred <= DC.Predicates[DC.Predicates.Count - 1].StartIndex + DC.Predicates[DC.Predicates.Count - 1].Size); if (DC.Predicates[pid].ParamCount == 0) { sb.Append(DC.Predicates[pid].Name); return; } int linearIndex = pred - DC.Predicates[pid].StartIndex; List <int> lst = Enumerable.Range(0, DC.Predicates[pid].ParamCount).ToList(); DC.GetMultiIndex(linearIndex, ref lst); sb.Append(DC.Predicates[pid].Name); sb.Append("("); sb.Append(DC.GetObjectString(lst[0])); for (int i = 1; i < lst.Count; i++) { sb.Append(", "); sb.Append(DC.GetObjectString(lst[i])); } sb.Append(")"); }