我有一个圆圈里的补丁,代表海龟进入的东西。最后,在运行行为空间实验时,我希望能够测量每只海龟到该圆边缘的距离,并且我想报告它的净值。我不断收到错误,我不知道该怎么做。
我尝试将最终坐标和初始坐标设置为“patch-here”。但是我不断遇到问题,说“您不能在观察者上下文中使用 INITIAL-COORD,因为 INITIAL-COORD 仅适用于海龟”。
;我的代码以 350 滴答结束,这是在 go 函数中...
if ticks = 350
[ask rbc [ set final-coord patch-here ]
ask initial-coord [set dist dist + distance final-coord]
set dist dist / (count rbc)]
;然后当我尝试从我的数据中创建一个文件时......
to makeOutputFile
set fileCounter 0
let date date-and-time
repeat 16 [set date remove-item 0 date]
set output_folder (word "Experiments/")
while [file-exists? (word output_folder"run_"fileCounter"_"date"_output.txt")][set fileCounter fileCounter + 1]
let output_file(word output_folder"run_"fileCounter"_"date"_output.txt")
file-close-all
file-open output_file
file-write ( "dist:")
file-write (dist)
end