kay21
kay21

Reputation: 43

change the value of a link

I try to change the values of links for only the links to particular agents. So, I want to set the links of myself to every agent in the agent set relatedPersons to 0.6 and keep all other links unchanged. Can I achieve this using ask my-out-links? My code is:

breed [ persons person ]

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

to setup
  clear-all 
  create-persons 10
  [
    set grouped false
  ]
  create-connections
  reset-ticks
end

to create-connections
  ask persons
  [ setup-connection ]
end

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

to increaseConnection
  let alonePersons count persons with [grouped = false]
  let relatedPersons n-of (random alonePersons) persons
  ask relatedPersons [
    ask my-out-links [ set trust 0.6 ]
  ]
end

to go
  increaseConnection
  tick
end

Upvotes: 1

Views: 54

Answers (1)

Charles
Charles

Reputation: 4168

I think that this is the line that you want. Not terribly efficient as the intimacy value is set by both members of the pair, but it is intuitive and unless you have a lot of protesters, it should not be a problem.

ask my-out-links with [member? other-end NRelatedProtesters] [ set intimacy 0.8 ]

Each protester is looking for its links where the other end is a member of the NRelatedProtesters group.

Actually, to be consistent with your model, it should be

ask my-out-relationships with [member? other-end NRelatedProtesters] [ set intimacy 0.8 ]

Do note that your code is not complete. If one wanted to test it, they would have to fill in a number of missing parts.

Upvotes: 1

Related Questions