We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Sorting example? (Read 406 times)
Sorting example?
Jun 28th, 2009, 3:57am
 
hi, im working on  agent simulation. I have 200 agents that moves randomly in the screen and each one calculates the distance between itself and the rest of the agents to know if it collide with other agent.
Having each agent calculating the distance between itself and the rest of agents is not very fast in terms of cpu consumption. Ive read before an technique called sorting that change the order of the elements of an array depending of its position in the screen in this way i dont need to calculate the distance between each agent and all the others but just calculate the distance between each agent and its neigbour in the array. I would like to know if somebody have an example of this technique or maybe theres some  code somebody want to share?


thanks in advance

Seb.


thanks


Seb.
Re: Sorting example?
Reply #1 - Jun 28th, 2009, 4:46am
 
you probably check it twice and against itself, thats where you can reduce it... i had some similar problems a year ago with a collition detection, they had some great hints and tipps :

http://processing.org/discourse/yabb2/?num=1218853051
Re: Sorting example?
Reply #2 - Jun 29th, 2009, 3:59am
 
amazing!!!
Page Index Toggle Pages: 1