예제 #1
0
    public List <AgentAwared> GetScouts(AgentAwared[] agents, int leader = -1)
    {
        if (agents.Length == 0)
        {
            return(new List <AgentAwared>());
        }
        if (agents.Length == 1)
        {
            return(new List <AgentAwared>(agents));
        }

        List <AgentAwared> agentList;

        agentList = new List <AgentAwared>(agents);
        if (leader > -1)
        {
            agentList.RemoveAt(leader);
        }
        List <AgentAwared> scouts;

        scouts = new List <AgentAwared>();
        float numAgents = (float)agents.Length;
        int   numScouts = (int)Mathf.Log(numAgents, 2f);

        while (numScouts != 0)
        {
            int         numA = agentList.Count;
            int         r    = Random.Range(0, numA);
            AgentAwared a    = agentList[r];
            scouts.Add(a);
            agentList.RemoveAt(r);
            numScouts--;
        }
        return(scouts);
    }
예제 #2
0
    //get the scouts, given a group of agents
    public List <AgentAwared> GetScouts(AgentAwared[] agents, int leader = -1)
    {
        if (agents.Length == 0)
        {
            return(new List <AgentAwared>(0));
        }
        if (agents.Length == 1)
        {
            return(new List <AgentAwared>(agents));
        }
        //remove the leader if given its index
        List <AgentAwared> agentList = new List <AgentAwared>(agents);

        if (leader > -1)
        {
            agentList.RemoveAt(leader);
        }

        //calculate the number of scouts to retrieve
        List <AgentAwared> scouts = new List <AgentAwared>();
        float numAgents           = agents.Length;
        int   numScouts           = (int)Mathf.Log(numAgents, 2f);

        //get the random scouts from the list of agents
        while (numScouts != 0)
        {
            int         numA = agentList.Count;
            int         r    = Random.Range(0, numA);
            AgentAwared a    = agentList[r];
            scouts.Add(a);
            agentList.RemoveAt(r);
            numScouts--;
        }
        return(scouts);
    }
예제 #3
0
 protected bool IsAffectedSound(AgentAwared agent)
 {
     //TODO
     //sound check implementation
     return(false);
 }
예제 #4
0
 protected bool IsAffectedSight(AgentAwared agent)
 {
     //TODO
     //sight check implementation
     return(false);
 }