// -----------------------------------------------------------------
 //  Simulates a pluck by replace all the values in the queue with
 //  a value from -0.5 to 0.5
 // -----------------------------------------------------------------
 public void pluck() {
   Random rand = new Random();
   for (int i = 0; i < frequency; i++) {
     chord.dequeue();
     double randomNum = -0.5 + rand.nextDouble();
     chord.enqueue(randomNum);
   }
 }
 // -----------------------------------------------------------------
 //  Dequeues, takes the average of it and the sample, then multiplies
 //  by .944 to create an energy decay factor
 // -----------------------------------------------------------------
 public void tic() {
   try {
     double note = chord.dequeue();
     double newnote = ((note + chord.first()) * 0.994) / 2;
     chord.enqueue(newnote);
   } catch (NullPointerException exception) {
     System.out.println("Empty array");
   }
 }
  private static boolean canAttackAny(RobotInfo attacker, BoundedQueue<RobotInfo> targets) {
    int size = targets.getSize();
    for (int i = 0; i < size; i++) {
      RobotInfo target = targets.remove();
      targets.add(target);
      if (attacker.type.canAttack()
          && attacker.location.distanceSquaredTo(target.location)
              <= attacker.type.attackRadiusSquared) {
        return true;
      }
    }

    return false;
  }
  public static BoundedQueue<RobotInfo> getEnemiesThatCanAttack(
      RobotInfo[] robots, MapLocation currentLocation, int maxEnemies) {
    BoundedQueue<RobotInfo> canAttack = new BoundedQueue<RobotInfo>(maxEnemies);
    int count = robots.length;
    for (int i = 0; i < count; i++) {
      RobotInfo enemy = robots[i];
      if (enemy.type.canAttack()
          && enemy.location.distanceSquaredTo(currentLocation) <= enemy.type.attackRadiusSquared) {
        canAttack.add(robots[i]);
        if (canAttack.isFull()) {
          return canAttack;
        }
      }
    }

    return canAttack;
  }
 // -----------------------------------------------------------------
 //  Constructor takes a frequency to build around
 // -----------------------------------------------------------------
 public GuitarString(double frequency) {
   this.frequency = frequency;
   final int sampleRate = 44100;
   int capacity = (int) Math.round(44100 / frequency);
   chord = new BoundedQueue<Double>(capacity);
   for (int i = 0; i < capacity; i++) {
     chord.enqueue((double) 0);
   }
 }
 // -----------------------------------------------------------------
 //  Returns the first value in the queue
 // -----------------------------------------------------------------
 public double sample() {
   return chord.first();
 }