巡逻程序(环路从A点移动到B点)

Patrol procedure (Loop moving from point A to point B)

我正在尝试从 A 点到 B 点得到一只乌龟 "patrol"。 这是我尝试过的:

-> to go procedure:
    to patrol
      set heading 90
      ifelse ( pxcor < 14 and pxcor > 6 ) 
      [ fd 0.1 ]
      [ bk 4 ]  
    end

它有效,但是当到达 else 语句时乌龟得到 "teleported",我知道上面的方法并不是真正的解决方案。

我需要乌龟以0.1的速度回到A点

您似乎希望在 A 点或 B 点旋转并继续行走。我就是这样做的。

to patrol ;; assuming the initial position is within 6 to 14.

  if pxcor = 14 or pxcor = 6 
  [ rt 180]
  fd .1 
end