Skip to main content
added 253 characters in body
Source Link
Sidar
  • 3.6k
  • 2
  • 17
  • 28

You might want to divide your world into segments/ a grid so that you only check collision for agents that are relevant. Agent A thats on the other side of the screen will NOT collide with B on te opposite side. So why check collision? Google for Spatial partitioning / quadtrees /spatial hashing.

I googled some for you:
Quadtrees
Grid

Also your second forloop should start at a1+1. Because all the previous agents were already checked And need no checking. This also eliminates the need of

if a1 == a2 : continue 

Because it starts one index ahead of a1.

You might want to divide your world into segments/ a grid so that you only check collision for agents that are relevant. Agent A thats on the other side of the screen will NOT collide with B on te opposite side. So why check collision? Google for Spatial partitioning / quadtrees /spatial hashing.

Also your second forloop should start at a1+1. Because all the previous agents were already checked And need no checking.

You might want to divide your world into segments/ a grid so that you only check collision for agents that are relevant. Agent A thats on the other side of the screen will NOT collide with B on te opposite side. So why check collision? Google for Spatial partitioning / quadtrees /spatial hashing.

I googled some for you:
Quadtrees
Grid

Also your second forloop should start at a1+1. Because all the previous agents were already checked And need no checking. This also eliminates the need of

if a1 == a2 : continue 

Because it starts one index ahead of a1.

Source Link
Sidar
  • 3.6k
  • 2
  • 17
  • 28

You might want to divide your world into segments/ a grid so that you only check collision for agents that are relevant. Agent A thats on the other side of the screen will NOT collide with B on te opposite side. So why check collision? Google for Spatial partitioning / quadtrees /spatial hashing.

Also your second forloop should start at a1+1. Because all the previous agents were already checked And need no checking.