algorhythm
algorhythm

Reputation: 3426

NetLogo: How can the heading of a turtle be passed onto another turtle within a radius?

A turtle reaches a point and for a set amount of time, can relate it's heading to other turtles within it's range.

Pseudo code

if any? turtles within 5
[pass on heading to other turtle]

The other turtle I'm assuming would need a call to use this heading, so something like

Pseudo code

if has received heading?
set heading new heading

Also I need to reverse this heading, so that the turtle receiving the heading does not travel at this heading, but rather travels in the opposite direction i.e the direction the other turtle was travelling from

Upvotes: 2

Views: 475

Answers (1)

Bryan Head
Bryan Head

Reputation: 12580

ask turtles in-radius 5 [
  set heading [ heading ] of myself
]

myself, aka the worst named primitive in NetLogo, refers to the turtle doing the asking.

Upvotes: 3

Related Questions