【发布时间】:2016-03-16 18:37:42
【问题描述】:
我有一个模型,我想测量乌龟以给定速度从一个点移动到另一个点所需的时间,使用地图的比例和速度/fd 移动来量化经过的实时时间。
我将所有船只的速度设置为一个随机数(UI 上的全局变量输入),并为每个海龟设置一个带有路径坐标的列表。我使用 time = distance / speed 的公式,但无法弄清楚如何准确计算时间。
速度设置为 30 左右的数字,我想将其用作 km/h。地图的比例是每个补丁 1000 米 x 1000 米,所以我尝试使用 1000 的因子来修复计算无济于事。以下是我对时间的计算。
to move
tick
ask ships with [length current-path != 0]
[
let x1 xcor
let x2 [pxcor] of first current-path
let y1 ycor
let y2 [pycor] of first current-path
let distance-traveled sqrt ((x2 - x1)^ 2 + (y2 - y1)^ 2)
set time ((distance-traveled * meters-per-patch) / (speed)
set timelist lput time timelist
set totaltime sum timelist
go-to-next-patch-in-current-path
]
end
这种药水调用运动。我正在划分速度/1000,因为速度的数字是 10,我希望海龟每个刻度移动的距离远少于 1 个补丁,以使其直接降落在列表中的补丁坐标上。
to go-to-next-patch-in-current-path
face first current-path
ifelse distance first current-path < .1
[
move-to first current-path
set current-path remove-item 0 current-path
]
[
fd speed / 1000
set heading towards first current-path
]
end
任何帮助将不胜感激,非常感谢。
【问题讨论】: