I am building a computer simulation of an N Body Problem for my science fair project. I want the simulation/code to playback when it finishes so that it can be constantly viewed by other people that walk by. I am using VPython
which has worked fine for making the simulation but I can't figure out a way to make all the objects go back to the initial position when restarting the whole code. My loop is using:
finished = False
while not finished:
rate(100)
then when certain things happen I use if statements to get the next part of the simulation going, ex: more stars
if time >= 4.5: #Millions of Years
F = G*(m1*m2)*r/r**3
does any body know how to make the whole code repeat its self? the best I could come up with is putting all the objects in the loop and then using continue, but I don't fully know how to use continue and break.
EX:
restPos = (x,y,z)
while True:
if Star1.pos = resetPos:
#reset star positions, EX below
star1.pos = (0,0,0)
else:
F = G*m1*m2*r/r**3
Star1.pos += F*dt #or however i did this, haven't used the code in a bit