I am trying to compare turtle labels in a social network.
The follow code is accepted grammatically by Netlogo but the logical test is not being carried out
Is there something obvious I have missed? i am wondering if the problem is that the turtles have multiple linked neighbors and I need to ask each neighbor in turn?
Many thanks for any suggestions
ask turtles with [contributor?]
[
ifelse label = [label] of link-neighbors ;; compare labels for affinity
[set affinity 15 ]
[set affinity 5 ]
For example, if the network consists of agents with labels A, B, C and the agent of interest has label A with 5 neighbors having random labels, then the comparison will look like the following:
Check if A = [B,C,A,A,B]
Since LHS is not equal to RHS, this always return false.
If you are interested in checking whether there is at least one other neighbor with label equal to the agent, then you can use the member? command as follows:
ifelse member? label [label] of link-neighbors
This checks if the label is a member of the list of labels of the link-neighbors