# How to find automous agents within range

**URL:** <https://discourse.processing.org/t/how-to-find-automous-agents-within-range/30575>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [June 8, 2021, 4:23pm UTC](https://discourse.processing.org/t/how-to-find-automous-agents-within-range/30575 "2021-06-08T16:23:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Goku557](https://avatars.discourse-cdn.com/v4/letter/g/e68b1a/32.png) [@Goku557](https://discourse.processing.org/u/Goku557)\
**Post date:** [June 8, 2021, 4:23pm UTC](https://discourse.processing.org/t/how-to-find-automous-agents-within-range/30575/1 "2021-06-08T16:23:58Z")

</div>

[sloved]

```auto
` void seek(PVector target) {
    // only run if mousecursor is pressed
    if (mousePressed) {
      // if creatures are nerby target
      float nerby=(10);
      for (Creature c : creatures) {
        float d = PVector.dist(target, c.position);
        if (d == nerby) {
          fill(a); // pink
          PVector desired = PVector.sub(target, position);
          desired.normalize();
          desired.mult(maxspeed);
          PVector steer = PVector.sub(desired, velocity);
          steer.limit(maxforce);
          applyForce(steer);
        }
      }
    } else {
      fill(c); //blue
    }
  }`

```

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [June 8, 2021, 10:22pm UTC](https://discourse.processing.org/t/how-to-find-automous-agents-within-range/30575/2 "2021-06-08T22:22:27Z")

</div>

> [@Goku557](#):
>
> `if (d == nerby) {`

d\<=nearby

Regards

Chrisir

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [June 8, 2021, 10:51pm UTC](https://discourse.processing.org/t/how-to-find-automous-agents-within-range/30575/3 "2021-06-08T22:51:46Z")

</div>

Yeah, 10 is also very small - maybe try 40

---

<div class="post-metadata">

**Author:** ![Goku557](https://avatars.discourse-cdn.com/v4/letter/g/e68b1a/32.png) [@Goku557](https://discourse.processing.org/u/Goku557)\
**Post date:** [June 8, 2021, 11:07pm UTC](https://discourse.processing.org/t/how-to-find-automous-agents-within-range/30575/4 "2021-06-08T23:07:42Z")

</div>

hey thanks for the reply but i’ve found another soloution to the problem and its works !
