【问题标题】:Leader Selection Form Swarm of Agents NetLogo领导者选择表 代理群 NetLogo
【发布时间】:2014-10-21 23:24:23
【问题描述】:

我想实现一个场景,即 NetLogo 模拟中的所有代理都应报告其邻居中代理的数量,半径最多为 3 个补丁。然后在其半径范围内拥有最多代理的前 3 个应该设置为领导者?真的 ' 。当我使用'海龟自己的 [ is-leader? ]'。

to setup
ca
ask n-of 30 patches [sprout 1 [
 set size .8
 ]
] 
end
to go
fd 0.5
lt random 20
choose-leader
end

to choose-leader


end

【问题讨论】:

    标签: netlogo


    【解决方案1】:

    试试这样:

    • 海龟有变量“是领导者?”设置为假。

    • 海龟在每个滴答声中以您决定的随机方式移动,然后设置它们的“是领导者?”变量为假

    • 执行过程选择领导者。它选择半径为 3 的邻居数量较多的 3 只海龟,并设置它们的“是领导者?”为真。

    代码:

     turtles-own[
       is-leader?
    ]
    
    to setup
      ca
      ask n-of 30 patches [sprout 1 [set size .8 set is-leader? false]] 
    end
    
    to go
      ask turtles[
         fd 0.5
         lt random 20
         set is-leader? false
      ]
      choose-leader
    
    end
    
    to choose-leader
    
       ask max-n-of 3 turtles [count turtles in-radius 3] [set is-leader? true]
    
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-08-01
      • 2011-08-15
      • 1970-01-01
      • 2017-06-07
      • 2021-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多