【发布时间】:2019-02-25 21:05:29
【问题描述】:
我正在模拟有界天使内的随机游走,我想在我的模型中计算 2D 中海龟的 mean squared displacement。海龟都是从中心开始的。我不确定在海龟到达边界后如何更新它们的 xy 坐标。我要求海龟在撞墙时反弹并保存新的 xcor 和 ycor。这是我的代码:
to go
ask turtles
[; head in a random direction in range (-theta, +theta)
ifelse theta = 0
[set heading heading + 0 ]
; choose a normally distributed random angel in range (-theta, +theta)
[set heading heading + random-normal 0 (theta)]
fd step-size
set xc xc + (step-size * dx)
set yc yc + (step-size * dy)
; if your next patch is blocked:
ifelse not can-move? 1
[ set heading heading + 180
fd 1 ]
;otherwise:
[rt random-float random-normal 0 (theta)]
set xcor xc
set ycor yc
set dist sqrt (xc * xc + yc * yc)]
]
我收到错误消息: “不能将乌龟移动到世界边缘之外。 龟 423 运行 SET 时出错 由过程 GO 调用 由按钮“go”调用。任何想法为什么?
【问题讨论】:
标签: distance netlogo agent-based-modeling