from cs1graphics import *
from math import sqrt
numLinks = 50
restingLength = 20.0
totalSeparation = 630.0
elasticityConstant = 0.005
gravityConstant = 0.110
epsilo
If it helps, here is the explanation taken directly from page 189 of the book (Object Oriented Programming in Python), immediately below the presentation of the piece of code given:
"An important subtlety in our approach is seen at line 52. This line causes oldChain to be a copy of the chain. Note that this is quite different semantics from the command oldChain = chain, which would simply make the identifier oldChain reference the same underlying list. The need for this copy is as follows. The inner for loop is used to recompute the position of each interior point of the chain, one by one. We want to do all of those computations based upon a coherent state of the chain. If we had not made a copy, we would run into the following trouble. The adjustment to the second point in the chain depends on the positions of the first and third points. Suppose that we were to make that adjustment and then continue. The next step would be to calculate the adjustment to the third point, which depends on the positions of the second and fourth points. But now there would be a discrepancy between the preceding position of the second point and its updated position. We want to use the preceding position of the second point for consistency. For this reason, we compute all forces based upon the copy of the old chain."