Ejemplo n.º 1
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
    }
Ejemplo n.º 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().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);
    }
Ejemplo n.º 3
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;
        }
    }
Ejemplo n.º 4
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);
        }
    }
Ejemplo n.º 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
     {
         knownFacts[name].Add(factValue);
     }
 }
Ejemplo n.º 6
0
    public void SetFact(string name, WorkingMemoryValue factValue) //add a fact to the clan facts
    {
        if (!knownFacts.ContainsKey(name))                         //If this type of fact dont exist in the facts 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 so att a new value for it

        {
            knownFacts[name].Add(factValue);
        }
    }
Ejemplo n.º 7
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);
        //}
    }
Ejemplo n.º 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);
        //}
    }
Ejemplo n.º 9
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);
        }
    }
Ejemplo n.º 10
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 {

            knownFacts[name].Add(factValue);
        }
    }
Ejemplo n.º 11
0
 public void RemoveFact(string clan, string factName, WorkingMemoryValue factValue)     //remove a fact for a clan
 {
     tribeFacts[clan].RemoveFact(factName, factValue);
 }
Ejemplo n.º 12
0
    //add a fact to the clan facts
    public void SetFact(string name, WorkingMemoryValue factValue)
    {
        if(!knownFacts.ContainsKey(name)){ //If this type of fact dont exist in the facts 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 so att a new value for it

            knownFacts[name].Add(factValue);
        }
    }
Ejemplo n.º 13
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);
            //}
    }
Ejemplo n.º 14
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);
        //}
    }
Ejemplo n.º 15
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);
        }
    }
Ejemplo n.º 16
0
 public void RemoveFact(string clan, string factName, WorkingMemoryValue factValue)
 {
     tribeFacts[clan].RemoveFact(factName, factValue);
 }
Ejemplo n.º 17
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);
        }
    }