1

We are using NetLogo for a simple infection. As a modell we use an imported gephi file. For our purpose we have to start the infection from the same turtle (meaning the one with the same specific label) for several times. In our code we have tried using the "who" number to make sure of that, but as soon as we setup, this number changes. So my question is: Is there the possibility to instead of the who number use the turtle's label in the code?

So far we have been using this code

extensions [nw]


globals
[
  num-informed
  informed-size
]

turtles-own
[
informed?
]

to setup
  clear-all
  nw:load-graphml "jk.graphml"
  ask turtles [ set size 1.5 ]
  layout-radial turtles links turtle 61
  ask turtles [set color red]
  ask turtles [set shape "dot"]
  ask links [set color grey + 1.5]
  ask patches [set pcolor white]
  ask turtles [set label-color black]
  ask turtles [set informed? false]
  ask turtle 72
  [
    set informed? true
    set color green
  ]
  set num-informed 1
  set informed-size 2
  reset-ticks
  nw:save-graphml "jk1.graphml"
end

to spread
  if (count turtles with [informed? = true] > .9 * count turtles) [stop]
  ask turtles with [ informed? = true ]
  [
      ask link-neighbors with [not informed?]
      [
        if (random-float 1 <= 0.02)
          [
            set informed? true
             show-turtle
            set color green
          ]
        ]
      ]

  set num-informed count turtles with [informed? = true]
  tick
end

Thank you so much!

  • 1
    Possible duplicate of [Changing Node ID with every Setup in Netlogo](http://stackoverflow.com/questions/34908040/changing-node-id-with-every-setup-in-netlogo) – JenB Jan 21 '16 at 14:44
  • I think you are right. Although using labels would be a good solution. ala one-of turtles with [label = "this one"] – King-Ink Jan 21 '16 at 14:52

1 Answers1

2

As King-Ink said in a comment, you can get a turtle with a particular label by doing one-of turtles with [ label = "some label" ]

Bryan Head
  • 12,360
  • 5
  • 32
  • 50