Peter Qiu
Peter Qiu

Reputation: 942

World wrapping and chase angles

I'm trying to make one turtle chase a small group of other turtles, and the turtles being chased turn away from the pursuer at this angle:

atan (xcor - [xcor] of pursuer) (ycor - [ycor] of pursuer)

When the world is wrapped, subtracting coordinates obviously fails to work, so I was wondering if anyone had encountered this problem before or could figure out a solution?

Upvotes: 3

Views: 189

Answers (1)

Frank Duncan
Frank Duncan

Reputation: 358

Try using the reporter towards as it takes world topology into account: http://ccl.northwestern.edu/netlogo/docs/dictionary.html#towards

For instance, if you'd like to move directly away from a target, you would do something along the lines of:

ask hunted [ set heading (towards hunter - 180) ]

Upvotes: 2

Related Questions