text: // Generated by CoffeeScript 1.11.1
  var Align;
  
  Align = (function() {
    function Align(options) {
      core.extend(this, core.defaults(options || {}, {
        enabled: true,
        agents: [],
        radius: 200,
        weight: 1.0,
        chance: 1.0
      }));
    }
  
    Align.prototype.apply = function(agent) {
      var average, count, distSq, i, len, other, radiusSq, ref, steer;
      if (!this.enabled || this.chance < 1 && Math.random() > this.chance) {
        return;
      }
      count = 0;
      average = new Vector();
      radiusSq = this.radius * this.radius;
      ref = this.agents;
      for (i = 0, len = ref.length; i < len; i++) {
        other = ref[i];
        if (!(other !== agent)) {
          continue;
        }
        distSq = Vector.distSq(agent, other);
        if (distSq > 0 && distSq < radiusSq) {
          average.add(other.vel);
          ++count;
        }
      }
      if (count > 0) {
        average.scale(1 / count);
        steer = Vector.sub(average, agent.vel);
        steer.scale(this.weight);
        return agent.acc.add(steer);
      }
    };
  
    return Align;
  
  })();
  