Пример #1
0
    public void RemoveFact(string factName, WorkingMemoryValue factValue)
    {
        //tempList is needed for 'collection has changed' if we change directly in list
        List<WorkingMemoryValue> tempList = GetFact(factName);
        foreach(WorkingMemoryValue wm in GetFact(factName))
        {
            if(wm.GetFactValue().Equals(factValue.GetFactValue()))
            {
                tempList.Remove(wm);
                break;
            }
            else
            {
                //Do nothing
            }
        }
        if(tempList.Count == 0)
        {
            knownFacts.Remove(factName);
        }
        else
        {
            knownFacts[factName] = tempList;
        }

        blackBoard.RemoveFact(clan, factName, factValue);
    }
Пример #2
0
    public void RemoveFact(string factName, WorkingMemoryValue factValue)
    {
        //tempList is needed for 'collection has changed' if we change directly in list
        List <WorkingMemoryValue> tempList = GetFact(factName);

        foreach (WorkingMemoryValue wm in GetFact(factName))
        {
            if (wm.GetFactValue() == factValue.GetFactValue())
            {
                tempList.Remove(wm);
                break;
            }
            else
            {
                //Do nothing
            }
        }
        if (tempList.Count == 0)
        {
            knownFacts.Remove(factName);
        }
        else
        {
            knownFacts[factName] = tempList;
        }
    }
Пример #3
0
    public void SetFact(string clan, string name, WorkingMemoryValue factValue)
    {
        bool alreadyKnown = false;

        foreach (WorkingMemoryValue vm in tribeFacts[clan].GetFact(name))
        {
            if (vm.GetFactValue().Equals(factValue.GetFactValue()))
            {
                //Already knows about it
                Debug.Log("Klanen vet redan det här!");
                alreadyKnown = true;
                break;
            }
        }

        if (!alreadyKnown)
        {
            tribeFacts[clan].SetFact(name, factValue);
        }

        if (name == "Agents")
        {
            tribeFacts[clan].ChangeNumberAgentsInClan(1);
        }
    }
Пример #4
0
    public void RemoveFact(string factName, WorkingMemoryValue factValue)     //Removes a fact from the workingmemory
    {
        //tempList is needed for 'collection has changed' error if we change directly in list
        List <WorkingMemoryValue> tempList = GetFact(factName);

        foreach (WorkingMemoryValue wm in GetFact(factName))
        {
            if (wm.GetFactValue().Equals(factValue.GetFactValue()))
            {
                tempList.Remove(wm);
                break;
            }
            else
            {
                //Do nothing
            }
        }
        if (tempList.Count == 0)
        {
            knownFacts.Remove(factName);
        }
        else
        {
            knownFacts[factName] = tempList;
        }

        blackBoard.RemoveFact(clan, factName, factValue);         //also remove the fact from the blackboard
    }
Пример #5
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);
        //}
    }
Пример #6
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);
        //}
    }
Пример #7
0
    public void SetFact(string clan, string name, WorkingMemoryValue factValue)     //set a new fact for a clan
    {
        bool alreadyKnown = false;

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

        if (!alreadyKnown)        //if we dont know the fact then add it
        {
            tribeFacts[clan].SetFact(name, factValue);
        }

        if (name == "Agents")        //if the fact is about a new agent increase the fact about number of agents
        {
            tribeFacts[clan].ChangeNumberAgentsInClan(1);
        }
    }
Пример #8
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);
            //}
    }
Пример #9
0
    public void SetFact(string clan, string name, WorkingMemoryValue factValue)
    {
        bool alreadyKnown = false;
        foreach(WorkingMemoryValue vm in tribeFacts[clan].GetFact(name))
        {

            if(vm.GetFactValue().Equals( factValue.GetFactValue()))
            {
                //Already knows about it
                Debug.Log("Klanen vet redan det här!");
                alreadyKnown = true;
                break;
            }
        }

        if(!alreadyKnown)
        {
            tribeFacts[clan].SetFact(name, factValue);
        }

        if(name == "Agents")
        {
            tribeFacts[clan].ChangeNumberAgentsInClan(1);
        }
    }
Пример #10
0
    //set a new fact for a clan
    public void SetFact(string clan, string name, WorkingMemoryValue factValue)
    {
        bool alreadyKnown = false;
        foreach(WorkingMemoryValue vm in tribeFacts[clan].GetFact(name))
        {

            if(vm.GetFactValue().Equals( factValue.GetFactValue()))
            {
                //Already knows about it
                alreadyKnown = true;
                break;
            }
        }

        if(!alreadyKnown) //if we dont know the fact then add it
        {
            tribeFacts[clan].SetFact(name, factValue);
        }

        if(name == "Agents") //if the fact is about a new agent increase the fact about number of agents
        {
            tribeFacts[clan].ChangeNumberAgentsInClan(1);
        }
    }
Пример #11
0
    //Adds a new fact to the workingmemory of the agent
    public void SetFact(string name, WorkingMemoryValue factValue)
    {
        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);
        //}
    }