## simulate many coins flipping at once. ## Have a reference coin (coin on the far right) and coins ## with slightly different initial angles. See how small the ## difference in angle must be for a coin to have the same ## result as the reference coin. from CoinFlipModule import * scene.autoscale = 0 floor=box(color=color.white, pos=(0,-0.3,0), height=0.4,width=8,length=36) ## make a list of coins - they only differ in their initial angle. ref_angle = 1.0 coinlist = [] for i in range(9): anglediff = 0.1**i xposition = i * 3 - 12 print "adding coin with difference in angle of", anglediff c = makecoin(xposition, ref_angle + anglediff) coinlist.append(c) # add reference coin - this is the coin on the far right coinlist.append(makecoin(15, ref_angle)) print "Reference coin is at x=15, with angle ",ref_angle dt = 0.002 ## while the reference coin is still moving while coinmoving(coinlist[9]): # update all of the coins in the list (0.08 is the momentum # lost in each bounce - if 0, would bounce forever.) for coin in coinlist: coinupdate(coin, 0.08, dt)