How to move to a linked agent which has a particular value for the link

Viewed 29

I am trying to select the agents to which I link that have a high value for my link to that agent. Then, I want to move to one of those agents. I cannot figure out how to select the agents at the other end of my link, where the link has a particular value and then move to one-of those agents with a high value of 0.9 for the link. How can I achieve this?

breed [ people ]
undirected-link-breed [ connections connection ]
connections-own [ trust ]

to setup-all-connections
  ask people [setup-connection]
end

to setup-connection
  create-connections-with other people [set trust 0.4]
end

to go
  move-people
  tick
end

to move-people 
  ask people [
    let chance random 100
    if chance < 80
    [
      let highTrust my-out-connections with [trust = 0.9]
      move-to one-of people with [member? other-end highTrust]
    ]
  ]
end
1 Answers

How about

let highTrust turtle-set [other-end] of my-out-connections with [trust = 0.9]
move-to one-of highTrust

I.e., get a list of the appropriate other-ends, turn that list into an agentset, and then move to one of them. Or, more economically

move-to one-of [other-end] of my-out-connections with [trust = 0.9]

since one-of works on lists of agents as well as agentsets. You may need to be sure that their is at least one such trusted agent before applying one-of. You might also want to check if there is already a trusted agent at the same location so that it does not move away from it.

Related