海龟分布
如何创建一组位置从环境边缘到中间呈上升分布的海龟?
How to create a set of turtles with the rising distribution of their location from the edge of the environment to the middle?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在设置中使用类似的东西,
如果您启用了世界环绕,那么它将起作用。如果世界环绕关闭,则必须添加一些代码来检查随机法线的 xcor 和 ycor 值是否在世界范围内(例如,乌龟的新 xcor 位于 min-pxcor 和 max-pxcor 之间)--否则,代码有时会尝试将新乌龟放在空间之外,这是一个错误。
您还可以使用三角形分布来线性改变海龟的密度,从空间中心的峰值到边缘的零。
NetLogo 没有内置这种三角分布,因此您需要将此过程添加到您的代码中:
You can use something like this in setup
That will work if you have world-wrapping on. If world-wrapping is off, you would have to add some code to check that the values of xcor and ycor from random-normal are within the world (e.g., the turtle's new xcor is between min-pxcor and max-pxcor) -- otherwise, the code will sometimes try to put the new turtle outside the space, which is an error.
You could also use a triangular distribution that varies the density of turtles linearly from a peak at the center of the space to zero at the edge.
NetLogo does not have this triangular distribution built-in, so you need to add this procedure to your code: