public void ReloadConcepts() { conceptNames = new List <string>(); conceptDictionary = new TwoWayList <int, Fuzzy.Concept>(); displayFunctions = new List <bool>(); functionDictionary = new Dictionary <Fuzzy.Concept, TwoWayList <int, Fuzzy.Function> >(); //Fills the conceptDictionary container and gather the concept names for (int conceptKey = 0; conceptKey < _owner.ConceptList.Count; conceptKey++) { Fuzzy.Concept concept = _owner.ConceptList[conceptKey]; displayFunctions.Add(false); conceptNames.Add(concept.name); conceptDictionary.Add(conceptKey, concept); functionDictionary.Add(concept, new TwoWayList <int, Fuzzy.Function>()); //Fills the function two-way list of the current concept for (int j = 0; j < concept.Functions.Count; j++) { functionDictionary[concept].Add(j, concept.GetFunction(j)); } } }
public Fuzzy.Concept GetConceptFomConditionExnpression(int conditionIndex, int expressionIndex) { _currentConcept = null; _currentConcept = GetConceptByIndex(conceptIndexes[conditionIndex][expressionIndex]); return(_currentConcept); }
public Fuzzy.Concept AddConceptInCurrentConditionExpressionList(int conditionIndex, int conceptIndex) { conceptIndexes[conditionIndex].Add(conceptIndex); _currentConcept = null; _currentConcept = GetConceptByIndex(conceptIndex); return(_currentConcept); }
public int GetConceptIndex(Fuzzy.Concept concept) { if (conceptDictionary.Contains(concept)) { return(conceptDictionary[concept]); } return(-1); }
public void RemoveConceptName(Fuzzy.Concept concept) { foreach (var name in conceptNames) { if (name == concept.name) { conceptNames.Remove(name); break; } } }
public void ResetExpressionsUsingConcept(Fuzzy.Concept concept) { for (int i = 0; i < conceptIndexes.Count; i++) { for (int j = 0; j < conceptIndexes[i].Count; j++) { if (conceptIndexes[i][j] == conceptDictionary[concept]) { conceptIndexes[i][j] = 0; functionIndexes[i][j] = 0; } } } }
public Fuzzy.Concept GetConceptByIndex(int index) { _currentConcept = null; try { _currentConcept = conceptDictionary[index]; } catch (KeyNotFoundException) { Debug.LogWarning("@" + GetType() + " - Key exception. Could not find the key inside concept dictionary"); } return(_currentConcept); }
public int GetFunctionIndexFromConcept(Fuzzy.Function function, Fuzzy.Concept inConcept) { if (inConcept.GetFunction(function)) { for (int i = 0; i < inConcept.Functions.Count; i++) { if (function.Equals(inConcept.Functions[i])) { return(i); } } } return(default(int)); }
public Fuzzy.Concept SetConceptForCurrentConditionExpression(int conditionIndex, int expressionIndex, int conceptIndex) { try { conceptIndexes[conditionIndex][expressionIndex] = conceptIndex; _currentConcept = null; _currentConcept = GetConceptByIndex(conceptIndex); } catch (System.ArgumentOutOfRangeException) { Debug.LogError("@" + GetType() + " - Index exception. Invalid index for condition or expression list"); } return(_currentConcept); }
private void FuzzyCalculations() { _fBehaviour.SetConceptValue("Distancia", distancia); _fBehaviour.SetConceptValue("Vida", vida); _fBehaviour.SetConceptValue("Municao", municao); _fBehaviour.SetConceptValue("Inimigos", inimigos); _fBehaviour.ExecuteConditions(); Fuzzy.Concept __risco = _fBehaviour.GetConcept("Risco"); for (int i = 0; i < _fBehaviour.GetConcept("Risco").Functions.Count; i++) { print("Concept " + __risco.Functions[i].Name + ": " + __risco.Functions[i].Fuzzy); } print("Defuzzy: " + __risco.Defuzzyfication(0.001f)); }
public Fuzzy.Function GetFunctionFromConceptByIndex(Fuzzy.Concept concept, int index) { _currentFunction = null; try { _currentFunction = functionDictionary[concept][index]; } catch (KeyNotFoundException) { Debug.LogWarning("@" + GetType() + " - Key exception. Could not find the key inside function dictionary"); } catch (System.IndexOutOfRangeException) { Debug.LogWarning("@" + GetType() + " - Index exception. Invalid index for selected concept's function list"); } return(_currentFunction); }
public ConditionExpression(Concept c, Function f, Operator op) { Concept = c; Function = f; Operator = op; }