       influence = @affinity other
       if influence
         data = @others[other.id]
-        influence /= Math.pow( gd[data], 2 )
+        d = gd[data]
+        influence /= d * d
         influence *= @g()
         [ xa, ya ] = g.vector data, influence
         x += xa
         y += ya
     if x || y
-      m = Math.sqrt( x*x + y*y )
+      m = Math.sqrt( x * x + y * y )
       if m > @maxAcceleration()
         f = @maxAcceleration() / m
         x *= f

    createCreatures Herbivore, 'herbivores'
    createCreatures Carnivore, 'carnivores'
    # keep an inert instance of each type in its initial state
    @seeds = {
      'plant'     : new Plant [0,0], paramsForType( 'plants', true )
      'herbivore' : new Herbivore [0,0], paramsForType( 'herbivores', true )
      'carnivore' : new Carnivore [0,0], paramsForType( 'carnivores', true )
    }

  # fetch the initial version of a particular type of organism
  urThing: (type) -> @seeds[type.toLowerCase()]
  addThing: (thing) ->
    thing.id = @idBase += 1
    @addToCollection thing, @things
  addToCollection: (thing, collection) ->
    if thing instanceof Animal
      @trig thing, t for t in collection
    else
      @trig t, thing for t in collection when t instanceof Animal
    collection.push thing
  # do all recalculations without yielding any time to browser events
  fastRecalculate: ->
    fresh = []
    setTimeout(
      =>
        t.clean() for t in @things
        @addToCollection thing, fresh for thing in @things
        @things = fresh
        @afterGeometry()
      0
    )
  # yield frequently to the browser while recalculating events
  responsiveRecalculate: ->
    fresh = []
    nextThing = =>
      if @things.length
        t = @things.shift()
        @addToCollection t, fresh
        setTimeout nextThing, 0
      else
        @things = fresh
        @afterGeometry()
    nextThing()
  remThing: (thing) ->
    thing.dead = true
    @change = true
    for v in ( thing.marges || [] )
      @geoPool.push v
    for k, v of thing.others when v
      @geoPool.push v
    for t in @things
      v = t.others[thing.id]
      if v?
        @geoPool.push v if v
        delete t.others[thing.id]
  # moves a thing based on that things velocity, handling reflection off
  # the edges of the universe
  moveThing: (thing) ->

  babies: ->
    cradles = @makeCradles()
    orchards = @makeCradles()
    @visitThings(
      (t) =>
        points = @pointsNear t.x, t.y, t.radius * 2
        @removeCradles cradles, points unless t instanceof Plant
        @removeCradles orchards, points unless t instanceof Stone
      false, true
    )
    @visitThings (t) ->
      if t instanceof Organism
        c = if t instanceof Plant then orchards else cradles
        t.reproduce c
  findCradles: (allCradles, newCradles) ->
    grep newCradles, (pt) -> allCradles[pt[0]][pt[1]]
  removeCradles: (allCradles, points) ->
