Пример #1
0
    public void SetFact(string name, WorkingMemoryValue factValue)
    {
        if (!knownFacts.ContainsKey(name))
        {
            List <WorkingMemoryValue> tempList = new List <WorkingMemoryValue>();
            tempList.Add(factValue);
            knownFacts.Add(name, tempList);
        }
        else
        {
            //Check if already exist

            bool alreadyKnown = false;

            foreach (WorkingMemoryValue vm in knownFacts[name])
            {
                if (vm.GetFactValue().Equals(factValue.GetFactValue()))
                {
                    //Already knows about it
                    alreadyKnown = true;
                    Debug.Log("!!!!!!!!!!!!! already know this!");
                    break;
                }
            }

            if (!alreadyKnown)
            {
                Debug.Log("Adding information to workingMemory!");
                knownFacts[name].Add(factValue);
            }
        }
        //Check if it is a globaly important fact that everyone needs to know about, then send it to the blackboard
        //if(name == "Red" || name == "Blue" || name == "Yellow" || name == "Buildings" || name == "Orange" || name == "Green" || name == "Magenta")
        //{
        blackBoard.SetFact(clan, name, factValue);
        //}
    }
Пример #2
0
    public void SetFact(string name, WorkingMemoryValue factValue) //Adds a new fact to the workingmemory of the agent
    {
        if (!knownFacts.ContainsKey(name))                         //If this type of fact dont exist in workingmemory then need to add a new list with the fact of the new fact type, ex. knownFacts["Buildings"]
        {
            List <WorkingMemoryValue> tempList = new List <WorkingMemoryValue>();
            tempList.Add(factValue);
            knownFacts.Add(name, tempList);
        }
        else             //The fact type already excist

        //Check if we already have the same value in the memory
        {
            bool alreadyKnown = false;

            foreach (WorkingMemoryValue vm in knownFacts[name])
            {
                if (vm.GetFactValue().Equals(factValue.GetFactValue()))
                {
                    //Already knows about it
                    alreadyKnown = true;
                    break;
                }
            }

            if (!alreadyKnown)            //If we dont have it then add it
            {
                knownFacts[name].Add(factValue);
            }
        }

        //Check if it is a globaly important fact that everyone needs to know about, then send it to the blackboard
        //if(name == "Red" || name == "Blue" || name == "Yellow" || name == "Buildings" || name == "Orange" || name == "Green" || name == "Magenta")
        //{
        //Also add the fact to the global blackboard for the clan so everyone knows about it
        blackBoard.SetFact(clan, name, factValue);
        //}
    }