I have two agentsets. Are there functions for finding:
I'm finding it very difficult to implement this by hand, especially when it's needed inside of a triple ask
Ideal use would be similar to with
syntax:
let cross set1 and-in set2
let uniq set1 with [color = red] not-in set2
Simple things like "Is agent A in the agentset X?" are problematic
For the first one you use the turtle-set
primitive. For the second one you need the member?
primitive, which also works on agentsets. As such:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With