Til Hund
Til Hund

Reputation: 1681

Netlogo: I can move-to expect agent, but got nobody once in a while

With regards to this question MOVE-TO expected input to be an agent but got NOBODY instead, I regularly encounter the same issue, however, even if I write a move-to that is protected by an if any?.

Imagine the following scenario, I have two breed, and one is ask to approach a member of the other breed if conditions are met. This is what breed1 executes:

if any? breed2 [
    ifelse var >= 5 [
      move-to one-of breed2 in-radius 2
    ]
    [ ... ] 
  ]

If, breed2 is not in-radius or no member of breed1 has a var above 5, I get the above mentioned error message. How can I avoid it?

Upvotes: 0

Views: 126

Answers (1)

JenB
JenB

Reputation: 17678

your move-to is NOT protected by an if any? clause. The if checks whether there are any turtles of breed2, regardless of their distance, but your move-to requires there to be one within a certain distance.

Upvotes: 3

Related Questions