示例#1
0
  protected void placeFoxes() {
    foxes = new ArrayList<>(par.numFoxes);

    double range = par.arenaSize / par.numFoxes;

    for (int i = 0; i < par.numFoxes; i++) {
      Fox f = new Fox(this, field);
      Double2D newLoc = null;
      if (par.randomFoxPosition) {
        newLoc =
            new Double2D(
                par.foxX * par.arenaSize,
                i * range + f.getRadius() + random.nextDouble() * (range - f.getRadius() * 2));
      } else {
        newLoc = new Double2D(par.foxX * par.arenaSize, i * range + range / 2);
      }
      f.setLocation(newLoc);
      foxes.add(f);
      schedule.scheduleRepeating(f);
    }
  }