This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-03-22 15:44:58

mainiacjoe
Scratcher
Registered: 2010-04-11
Posts: 8

Best way to implement n-body simulations

What is the best way to handle multiple similar sprites, that each need to be able to interact with all of the other individually?  For instance, an ideal gas model where each molecule needs to bounce of any molecule it touches, or an star cluster simulation where each star responds to the gravity of all the others?  I know how to do it manually, but I was hoping that there might be a way to use lists so that it would be less labor intensive to tweak it.

Thanks,

- Joe

Offline

 

#2 2011-03-22 16:04:56

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Best way to implement n-body simulations

One approach might be to use lists to maintain the state of the individual bodies...then use a single sprite to stamp the location of each body during the display loop.  It would be pretty slow but might be acceptable in Turbo mode in Scratch or the Flash viewer.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#3 2011-03-24 12:06:17

edguan
New Scratcher
Registered: 2011-01-03
Posts: 1

Re: Best way to implement n-body simulations

A good way is to use stamp, I try to demonstrate it here

http://scratch.mit.edu/projects/edguan/1677482

Offline

 

Board footer