示例#1
0
// ===============================================================================================
// method to find nearby neignbours to each agent
// ===============================================================================================
        private List <IFlockAgent> FindNeighbours(IFlockAgent agent)
        {
            List <IFlockAgent> neighbours = new List <IFlockAgent>();

            foreach (IFlockAgent neighbour in IAgents)
            {
                if (neighbour != agent && neighbour.Position.DistanceTo(agent.Position) < NeighbourhoodRadius)
                {
                    neighbours.Add(neighbour);
                }
            }

            return(neighbours);
        }
示例#2
0
// ===============================================================================================
// method to compute desired velocity of agent based on behaviours applied
// ===============================================================================================
        private void ComputeAgentDesiredVelocity(IFlockAgent agent)
        {
            List <IFlockAgent> neighbours = FindNeighbours(agent);

            agent.ComputeDesiredVelocity(neighbours);
        }