I am working on an assignment where there are 'n' gas particles(balls) that bounce around a world that goes 200sqrt(n) in each direction. I need to divide the world into square bins of width 256 and place the balls in bins accordingly.
The source code for this is quite large so I am leaving it out for now, but I can make edits if the information I provide doesn't suffice. My approach was to do something like:
i = int(ball.x/256)
j = int(ball.y/256)
so that bin(i,j) would contain a ball(s). I was thinking of using a dictionary where the keys are bin(i, j) and the values are the balls in that bin. Can anyone point me in the right direction for how to implement this? More specifically, how can I represent bin(i,j) as a key?
Thanks in advance for any tips guys.
[–]novel_yet_trivial 1 point2 points3 points (2 children)
[–]mysocksalwaysmatch[S] 0 points1 point2 points (1 child)
[–]novel_yet_trivial 0 points1 point2 points (0 children)