有没有办法让海龟验证他们是否有链接或邻居?
我需要一种方法让海龟检查他们是否有链接。如果乌龟这样做,那么我需要它将变量SocialST更改为1.如果乌龟没有,那么它应该跳过。这是我到目前为止设计的......
to SocialStructure
ask turtles with [link-neighbors]
[if (abs([SN] of self - [SN] of one-of link-neighbors) >= Soctol ) [Set SocialST 1]]
端
答案 0 :(得分:2)
对代码进行微小更改:
to updateSocialStructure
ask turtles with [any? link-neighbors] [
if (abs([SN - [SN] of one-of link-neighbors) >= Soctol )) [Set SocialST 1]
]
end
但你真的想要one-of
吗?