0

I'm trying to make a network of friends like in this example previous to the final correction of JenB in here, since it is more comprehensible for me and Bryan Head said it would be the way he would do it with fewer agents. I'm planning to use around 200, maybe 300 agents.

My question is... how could I do it without forming pairs? I want the agents to make friends with every agent in radius x during y ticks and with the same color (I'm still working on the tick condition). I tried with if and some conditions before finding the JenB example but it was way too heavy.

I think it isn't necessary to rework the full code. But I'll write it down for you to see my version.

to make-friends
ask agentes [
let new-friendships friends - count my-friendships
if (new-friendships > 0) [
  set possible-friends other agentes in-radius sight-radius with [
    (count my-friendships < friends) and (color = [color] of myself) ]
  create-friendships-with n-of min (list new-friendships count possible-friends) possible-friends]
end

V2 CODE

I started to work in another piece of code since I don't fully know how to do it better. This is the last version. The random-in-range 0 12 condition is in the setup.

to make-friends
  ask agentes [
    let new-friends max-friends - count my-friendships
    let possible-friends other agentes with [color = [color] of myself] in-radius sight-radius
    if new-friends > 0 [
      let chosen n-of min (list new-friends count other possible-friends) other possible-friends
      create-friendships-with chosen ;in-radius sight-radius [ hide-link ]
      set possible-friends other possible-friends
      set friends friendship-neighbors
      ask chosen [
        if my-friendships = friends [ set possible-friends other possible-friends ] ]
    ]
  ]
end
  • If the turtle is forming friendships with all turtles that match some conditions (same color, in-radius etc) then you don't need anything this complicated. This code is to enforce an upper limit on the number of friends. Please clarify whether there is some limit to the number of friends, or whether the turtle makes a link with every eligible turtle. – JenB Jul 19 '17 at 23:10
  • Of course, sorry. Now (I reworked a bit the conditions) the turtles have a `random-in-range 0 12` limit. But only because they become friends easily and I don't want everybody in the network. Right now it is fairly slow (5 seconds for 100 ticks). Without this piece of code they achieve 1000 ticks in 3 seconds. Later I'll add some way for them to change their culture based on their friends. I fear it will be terrible if I keep with this code. Added last version. – Jorge Martínez Jul 20 '17 at 12:53

0 Answers0