public IList <int> getGroupMembers(GroupAgent ga) { IList <Agent> groupAgents = ga.getAgents(); IList <int> toReturn = new List <int>(); foreach (Agent a in groupAgents) { toReturn.Add(a.id_); } return(toReturn); }
/** * <summary>Computes the interaction between this agent and all the others agents.</summary> */ public void interactWithAgents() { IList <GroupAgent> groups = new List <GroupAgent>(); for (int i = 0; i < agentNeighbors_.Count; ++i) { Agent neighbor = agentNeighbors_[i].Value; if (considerGroups_) { bool present = false; GroupAgent agentGroup = neighbor.groupBelongingTo_; // If the agent does not belong to any group or if it belongs to the same group, interact with it if (agentGroup == null || agentGroup == groupBelongingTo_) { interactWith(neighbor); } // Otherwise, add its group to the list of the groups to interact with else { foreach (GroupAgent g in groups) { if (agentGroup == g) { present = true; } } // If the group has not been selected yet, add it to the group list if (!present) { groups.Add(agentGroup); } } } else { interactWith(neighbor); } } // Interact with each group of the list for (int i = 0; i < groups.Count; ++i) { GroupAgent group = groups[i]; // If the group's representation succeded, interact with it SuperAgent groupRepresentation = group.representGroup(this); if (groupRepresentation.sim_ != null) { interactWith(groupRepresentation); } // Otherwise, interact with each agent of the group else { IList <Agent> agentsOfTheGroup = group.getAgents(); foreach (Agent a in agentsOfTheGroup) { interactWith(a); } } } }