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); }
//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); }
protected bool IsAffectedSound(AgentAwared agent) { //TODO //sound check implementation return(false); }
protected bool IsAffectedSight(AgentAwared agent) { //TODO //sight check implementation return(false); }