In NetLogo can I ask agents to die along a gradien

2019-07-27 07:16发布

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

标签: netlogo
1条回答
叛逆
2楼-- · 2019-07-27 07:56

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.

查看更多
登录 后发表回答