made gravity function faster

changed the loop to take half as many iterations, the distance^2 is used
to calculate the gravitational attraction of two objects at once, and the
gravity() function of the Thing constructor has been replaced with
gravity(i,j)

I am noticing some strangeness just after starting a simulation with this
new gravity, but it seems to sort itself out fine