Community

hi, Given a continuous space, I want to check whether there is agent within the range, say x from 100 to 150, y from 50 to 100, ( where x, and y are the coordinates). If there are any, I also want to get a random agent from this range. How can I do this? Thanks run
Run, you need just to compare coordinates of all agents with a point using the school formula: l = sqrt((x1-x2)^2 + (y1-y2)^2). When you collect all agents within the range added them to a collection or an array, you could select a random one using the method 'uniform'.
Run, I forgot that the Agent class has a special method calculating the distance from the agent to another one in continuous 2D space: distanceTo(Agent other).