Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Netlogo 在一块空地上移动海龟_Netlogo - Fatal编程技术网

Netlogo 在一块空地上移动海龟

Netlogo 在一块空地上移动海龟,netlogo,Netlogo,我正在尝试从世界上的随机位置开始,在0补丁周围移动海龟。但这个圈子还在继续扩大。我做错了什么 代码: to setup clear-all create-turtles 5 ask turtles [ setxy random-xcor random-ycor ] ask patch 0 0 [ set pcolor green ] reset-ticks end to go move-turtles tick end to move-turtles

我正在尝试从世界上的随机位置开始,在0补丁周围移动海龟。但这个圈子还在继续扩大。我做错了什么

代码:

to setup
  clear-all
  create-turtles 5
  ask turtles [
    setxy random-xcor random-ycor
    ]
  ask patch 0 0 [ set pcolor green ]
  reset-ticks
end
to go 
  move-turtles
  tick
end
to move-turtles
  ask turtles
  [
    face patch 0 0
    right 90
    fd 0.01
    set pen-size 3
    pen-down
   ]
end

第二,我想让一只海龟在我定义的任何一块地上移动,当它到达某个范围时

你的方法是沿着你想要的圆的切线走一小步,但这会让你在圆之外走一小步。你反复这样做,所以它会随着时间累积


要了解更好的方法,请参阅NetLogo模型库中的海龟旋转示例。

在该示例中,我不明白它在哪里指定了它应该移动的点?你能帮忙吗?它绕着它右边距离
r
的点转。可以修改公式以绕任意圆移动。或者可以像thils一样绕x,y旋转:
setxy x y fd r rt 90绕r旋转
(然后根据需要重复最后一个命令)。