我有两个代理集。是否有寻找功能:
我发现手动实现这一点非常困难,特别是在三重ask
理想用法与with
语法类似:
let cross set1 and-in set2
let uniq set1 with [color = red] not-in set2
简单的事情,例如“代理集X中的代理A?”是有问题的
答案 0 :(得分:12)
对于第一个,您使用turtle-set
原语。对于第二个,您需要member?
原语,它也适用于代理集。就这样:
to setup
ca
create-turtles 10 [set color red]
create-turtles 10 [set color blue]
let red-ones turtles with [color = red]
let blue-ones turtles with [color = blue]
;join 2 agent sets
let joinset (turtle-set red-ones blue-ones)
show joinset
let even-ones (turtles with [who mod 2 = 0])
;subtract even-ones from red-ones
let subtractset red-ones with [not member? self even-ones]
show subtractset
end