public IAction GenerateAction(SubstitutionSet constraints) { var actionName = m_actionTemplate.MakeGround(constraints); if (!actionName.IsGrounded) { return(null); } var targetName = Target.MakeGround(constraints); if (!targetName.IsGrounded) { return(null); } var priority = Priority.MakeGround(constraints); if (!priority.IsGrounded) { return(null); } var a = new Action(actionName.GetTerms(), targetName); //Determine Priority (Utility) float p = float.Parse(priority.ToString()); if (constraints.Any()) { var minCertainty = constraints.FindMinimumCertainty(); a.Utility = p + minCertainty; } else { a.Utility = p + 1; // minCertainty is 1 if there are no conditions to be uncertain about } return(a); }