Learn the direction of the moving agent

I created a turtle in NetLogo that moves randomly, and there are some obstacles. Is it possible to get its current direction? I want the turtle to return to the center when it sees an obstacle. I can calculate the distance to the center, but since I do not know its direction, I cannot say, for example, forward or backward.

+4
source share
3 answers

The facexy primitive allows you to set the turtle title to the origin:

http://ccl.northwestern.edu/netlogo/docs/dictionary.html#facexy

+3
source

The direction of the current of turtles is determined by the variable heading . You can read and write this variable to change the turtle title. You can also change it using facexy , as N. Payet noted.

+5
source
 ask turtle <who> [If (patch-ahead = obstacle) [ facexy origin fd distance origin ] ] 

Here the obstacles and the origin are the corresponding patches. Based on what Jose M Vidal and N. Payet have already said.

0
source

Source: https://habr.com/ru/post/1393766/


All Articles