在特定位置设置海龟 netlogo

set turtles in specific location netlogo

现在我有以下代码用于 "plants" 的初步规划,我希望它们以网格形式排列而不是随机排列(类似于真实区域,如附图所示):

这是我的代码:

;;init plants
  set-default-shape plants "plant"
  create-plants initial-number-plants [
    set color green
    setxy random-xcor random-ycor ;they are spread out randomly

    set is_susceptible true
    set is_infectious false

   ]

如有任何帮助,我们将不胜感激。

最简单的选择是使用 sprout 而不是 create。如果这还不够,请发表评论,我会写出完整的代码。

更新:完整程序(假设您有一个名为 'plants' 的海龟品种,具有关于易感性和传染性的变量)。我还稍微更改了您的变量名称以添加 ?最后,这是 true/false 变量的 NetLogo 约定。

to setup-plants
  set-default-shape plants "plant"
  ask n-of initial-number-plants patches
  [ sprout-plants 1
    [ set color green
      set is_susceptible? true
      set is_infectious? false
    ]
  ]
end

请注意,如果您的植物多于补丁,此代码将会中断。你的图表每个补丁只有一株植物,所以我不确定你想要什么。