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

StackOverflow https://stackoverflow.com/questions/22483907

  •  16-06-2023
  •  | 
  •  

Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top