使用标签代替NetLogo中的编号

时间:2016-01-21 10:41:36

标签: label text-editor netlogo

我们正在使用NetLogo进行简单感染。作为一个模型,我们使用导入的gephi文件。为了我们的目的,我们必须多次从同一只乌龟(意思是具有相同特定标签的海龟)开始感染。在我们的代码中,我们尝试使用" who"确保这一点的数字,但是一旦我们设置,这个数字就会改变。所以我的问题是: 是否有可能代替谁的号码在代码中使用海龟的标签?

到目前为止,我们一直在使用此代码

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

非常感谢你!

1 个答案:

答案 0 :(得分:2)

正如King-Ink在评论中所说,你可以通过one-of turtles with [ label = "some label" ]

获得一只带有特定标签的海龟