public void LoadProfile(string profileXML) { XmlDocument doc = new XmlDocument(); doc.LoadXml(profileXML); m_profile = new CFProfile(doc.SelectSingleNode("/Controller")); }
internal string CalculateOptimalSelection(float intendedDifficulty, CFProfile profile) { if (m_isGroupBinding) { CFLog.SendMessage("Trying to calculate single selection on group binding. Continuing...", MessageType.ERROR); } StringBuilder sb = new StringBuilder(); TrackedValue[] currentValues = profile.GetAllValues(); float currentBestDelta = float.MaxValue; int currentBestIndex = -1; for (int j = 0; j < m_outputList.Count; j++) { if (m_enableSelectionLock && profile.IsOutputLocked(m_name, m_outputList[j].returnString)) { sb.Append("Selection Locked: "); sb.Append(m_outputList[j].returnString); sb.Append("\n"); continue; } float difficulty = m_outputList[j].CalculateDifficulty(currentValues, sb); float delta = Math.Abs(intendedDifficulty - difficulty); sb.Append("Delta: "); sb.Append(delta); sb.Append('\n'); //This needs to mod delta, not difficulty if (m_discourageRepeatSelection) { int position = m_previousValues.IndexOf(m_outputList[j].id); //If the ID is in the previous list if (position != -1) { if (m_diminishingWeight) { position = m_previousTrackedValues - position; delta += delta * m_repeatSelectionWeight * //Ie if this object is 3rd in a 3 object list, 3/3 weight applied (position + 1) / m_previousTrackedValues; } else { delta *= m_repeatSelectionWeight; } sb.Append("\tIn previous Selection at Index "); sb.Append(position); sb.Append(". Modded to "); sb.Append(delta); sb.Append("\n"); } } if (delta < currentBestDelta) { currentBestDelta = delta; currentBestIndex = j; } } if (m_discourageRepeatSelection) { //Removes the value if it has already been placed into the queue m_previousValues.Remove(m_outputList[currentBestIndex].id); m_previousValues.Insert(0, m_outputList[currentBestIndex].id); //If the queue has exceded its count if (m_previousValues.Count > m_previousTrackedValues) { m_previousValues.RemoveAt(m_previousTrackedValues); } } sb.Append("Query Returning "); sb.Append(m_outputList[currentBestIndex].returnString); sb.Append(" delta: "); sb.Append(currentBestDelta); CFLog.SendMessage(sb.ToString(), MessageType.STATUS); if (m_enableSelectionLock) { profile.LockOutput(m_name, m_outputList[currentBestIndex].returnString); } return(m_outputList[currentBestIndex].returnString); }
/// <summary> /// Creates an XML string of the default settings /// </summary> /// <returns>Settings in a string format</returns> #region Profile public void CreateNewProfile(TrackedValue[] trackedValues) { m_profile = new CFProfile(trackedValues); }