let source one-of turtles
然后以某种方式将该品种作为我source
乌龟的属性(这不起作用)
let source-breed source.getBreed
有人可以帮帮我吗?
答案 0 :(得分:4)
正如您在NetLogo的文档中所看到的,each turtle has a breed
variable引用了包含该品种的所有海龟的代理集。您可以使用of
访问turtle变量,或在ask
块的上下文中引用它。
以下是一个例子:
breed [ mice mouse ]
breed [ cats cat ]
breed [ dogs dog ]
to go
clear-all
create-mice 10
create-cats 10
create-dogs 10
let source one-of turtles
show word "We picked: " source
show word "The source breed is: " [ breed ] of source
ask source [
let other-turtle one-of other breed
show word "Here is another turtle of the same breed: " other-turtle
]
end
请注意在one-of other breed
表达式中使用other
,这意味着“我的另一只乌龟”(不“是另一种海龟”。)< / p>