Network programming 信息传播

Network programming 信息传播,network-programming,netlogo,information-visualization,Network Programming,Netlogo,Information Visualization,netlogo有一个问题:我想在网络中传播信息。一只海龟拥有这些信息,并以恒定的概率将其提供给它的链接邻居。这是我目前掌握的代码: to spread if (count turtles with [informed? = true] > .7 * count turtles) [stop] ask turtles with [ informed? = true ] [ ask link-neighbors [ if (random-fl

netlogo有一个问题:我想在网络中传播信息。一只海龟拥有这些信息,并以恒定的概率将其提供给它的链接邻居。这是我目前掌握的代码:

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

  set num-informed count turtles with [informed? = true]
  tick
end
传播
如果(用[Notified?=true]>.7*计数海龟)[停止]
向海龟询问[知情?=正确]
[
询问链接邻居
[
如果(随机浮动1这应该有效(未测试)。假设您在设置海龟时已执行
设置通知?FALSE

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

  set num-informed count turtles with [informed?]
  tick
end
传播
如果(与[通知?]>.7*计数海龟一起计数海龟)[停止]
向海龟询问[知情?]

[ask link Neights with[not Notified?];**当变量X?为布尔值时(仅为TRUE或FALSE),你实际上不需要说
X?=TRUE
,可以简单地说
X?
,同样地
not X?
,因为
X?=FALSE
我想我没有修复他的错误信息了?好吧,现在已经没有错误信息了,我想它已经起作用了…非常感谢你的快速回答!@King Ink你已经修复了这个问题。但是你最初写的是,你已经修复了我会在晚饭后回来把它写得更好。我只是为你做了清理。你可以通过我名字上方的“编辑…”链接看到任何人都做了什么。是的,随机浮动被正确使用了