【发布时间】:2014-11-07 20:29:12
【问题描述】:
我在使用 Netlogo 中的 in-cone 命令时遇到了一些问题。我正在尝试直接在我的海龟当前位置(即它穿过的所有变量的总和)前面确定所有补丁变量的总和/平均值。然而,这似乎只在我的海龟位于补丁中心时才有效(坐标是整数而不是小数),这也意味着我只能以直角移动我的海龟。我还没有在 Stackoverflow 或其他地方找到与同一问题有关的任何其他问题。因此,如果有人能提供一些见解,我将不胜感激。
下面是简单的示例代码。我已经注释了在哪里进行更改会导致它不起作用。
干杯 保罗
turtles-own [value]
patches-own [value-test]
to Set-Up
ca
reset-ticks
ask patches [if pycor > 150 [set value-test 1]]
ask patches [if pxcor > 150 [set value-test 1]]
ask patches [if value-test = 1 [set pcolor red]]
create-turtles 1
ask turtles[
;It works when the turtle is created at the origin (0 0), or at defined coordinates (but not random-xcor random-ycor)
;setxy random-xcor random-ycor
set value 0
set size 10
set color yellow]
end
to go
ask turtles[
;heading has to be 0, 90, 180, or 270.
set heading 270]
ask turtles[
let test mean [value-test] of patches in-cone 10 1
print test
print xcor
print ycor
ask patches in-cone 10 1 [set pcolor blue]
forward 10]
end
【问题讨论】:
标签: netlogo