In NetLogo can I ask agents to die along a gradient from a central patch?

我与影子孤独终老i 提交于 2019-12-11 05:22:44

问题


In my model I have agents sprout at random throughout the environment. I'd like to to have a density gradient of these agents.

Is there a neater way to do it than running something like this for different radii?:

ask patch 0 0 [ask n-of 20 turtles in-radius 20 [die]]

Thanks


回答1:


You could do something along those lines:

to setup
  clear-all
  let max-distance max [ distancexy 0 0 ] of patches
  ask patches [
    if random-float 1.0 > (distancexy 0 0 / max-distance) [
      sprout 1
    ]
  ]
end

Many variants are possible. The key is to use a combination of random-float and distancexy 0 0 to get the density you want.



来源:https://stackoverflow.com/questions/37856220/in-netlogo-can-i-ask-agents-to-die-along-a-gradient-from-a-central-patch

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!