// a function that chooses the action depending on what goal needs to be satified the most public ActionSequence ChooseAction() { //this will be the goal that has the maximum utility (so is the highest on the list) //determines what goal it needs to take Goals MaxGoal = goallist[0]; foreach (Goals G in goallist) { if (G.GetValue() > MaxGoal.GetValue()) { MaxGoal = G; } } //find the action which satisfies the goal the most ActionSequence MaxAction = actionlist[0]; foreach (ActionSequence A in actionlist) { if (A.EvaluateGoalSatisfaction(MaxGoal.TypeReturn()) > MaxAction.EvaluateGoalSatisfaction(MaxGoal.TypeReturn())) { MaxAction = A; } } return(MaxAction); }