根据补丁值在NetLogo中发芽海龟 [英] Sprouting turtles in NetLogo based on patch value

查看:110
本文介绍了根据补丁值在NetLogo中发芽海龟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在NetLogo中加载了一个ASCII文件,其值(范围为0-4.6)表示栖息在该补丁中的海龟的平均数量(泊松过程).我想将模型设置为使用随机泊松在每个补丁上发芽海龟,并从ASCII文件中得出平均值.我知道如何ask n-of patches发芽一定数量的海龟,但我不知道如何要求发芽命令对所有补丁执行操作.任何帮助都会很棒!

I have loaded an ASCII file in NetLogo with values (ranging from 0 - 4.6) that represent the mean number (of a Poisson process) of turtles inhabiting the patch. I'd like to setup the model to sprout turtles on each patch using random-poisson with the mean value derived from the ASCII file. I know how to ask n-of patches to sprout a certain number of turtles but I don't know how to ask the sprout command to act on all patches. Any help would be great!

推荐答案

如果您的问题是询问所有补丁,则可以使用以下命令:

If your problem is asking all patches you can use following:

to setup 
  clear-all
  resize-world 0 10 0 10
  set-patch-size 40
  let ASCII-file-Values   n-values 121 [ random-poisson mean n-values 121[random-float 4.6]]
  let patches_list sort patches


  let i 0 
  foreach patches_list [
    ask ? [

      sprout item i ASCII-file-Values  
      set plabel count turtles-here
    ]
    set i i + 1
  ]

  reset-ticks      
end

回答您问题的唯一部分是foreach patches_list []如果您需要分配给补丁的值供以后使用,另一种方法是向每个补丁添加一个变量,并在foreach循环中设置此值,那么您可以ask patches [ sprout my-value]

The only section which answers your question is the foreach patches_list [] If you need values assigned to the patches to be used later, another way could be adding a varible to each patch and set this value in the foreach loop, then you can ask patches [ sprout my-value]

这篇关于根据补丁值在NetLogo中发芽海龟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆