或者如何将坐标添加到补丁集中?我想创建一个列表并添加访问的每个补丁,作为列表的另一个元素(使用lput),但是这个列表代替了补丁--这里每次我都尝试使用修补程序集,但是我不知道如何在它的末尾添加新的补丁并在那里添加坐标。
到目前为止,我的代码如下:
globals [ frontier frontier2 ]
breed [squares square]
breed [circles circle]
to setup
ca
set-default-shape squares "square"
set-default-shape circles "circle"
create-breeds
reset-ticks
end
to create-breeds
create-squares 1 [
setxy 0 0 ]
create-circles 1 [
setxy 5 5 ]
end
to go
ask squares [
fd 1
set frontier []
set frontier lput patch-here frontier
show frontier
]
ask circles [
fd 1
set frontier2 patch-set patch-here
show frontier2
]
tick
end这就是指挥中心所展示的:
“(方格0):(第7-3片)
(第1圈):(代理集,1个补丁)“
我期待类似于(方格0):(补丁0 0) (补丁1 0) (补丁2 0)
发布于 2015-03-29 16:58:51
它每次都会替换修补程序,因为每次在go过程中都要显式地重新初始化列表:
set frontier []只需将这一行移到setup过程中即可!
至于将修补程序添加到修补程序集而不是列表,正确的语法应该是:
set frontier2 (patch-set frontier2 patch-here)但我不建议您使用它,因为它每次都需要重新构建修补程序集,因此比使用list和lput要慢。而且,补丁集总是按随机顺序访问,我想这不是您想要的。
https://stackoverflow.com/questions/29328613
复制相似问题