NetLogo中基于区域大小的间隔代理 [英] Spacing agents in NetLogo based on territory size

查看:62
本文介绍了NetLogo中基于区域大小的间隔代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在NetLogo中开发一个模型,其中每次启动模型时,动物代理都会在整个空间中随机分布.但是,这些动物是地区性的.关于如何使动物从一定规模的圆形区域开始的任何建议,可以在一定程度上与其他动物重叠但不能完全重叠?下面是我已经开始的代码片段,但是坦率地说,我什至不知道从哪里开始.在下面的代码中,动物在初始化时并不知道其他领土.任何帮助将不胜感激.

I'm trying to develop a model in NetLogo in which animal agents will be randomly distributed across space each time the model is started. However, the animals are territorial. Any suggestions on how to have the animals start with a circular territory of some size that can overlap with other animals to a certain extent but not completely? Below is the fragment of code I have started on it, but frankly I don't even know where to start. In the code below the animals aren't aware of the other territories when initialized. Any help would be much appreciated.

to setup  
    ask n-of (number-of-animals) TropForst 
    sprout-animals 1
    set territory patches in-radius ((sqrt ((territory-animals * 1000000)/ pi)) / 10)
end

推荐答案

这是一种实现方法: 您可以更改每种动物的中心补丁,并可以设置其区域重叠的数量.

this is one way to do it : you can change the center patch for each type of animals and you can set how much you want their territory to overlap.

breed [animals animal]
animals-own [territory]
to setup  
  clear-all
    create-animals number-of-animals / 2  
    [
      set color red
    set territory pathces-in-territory patch 10 10
      move-to one-of territory 
      ]


   create-animals number-of-animals / 2  
    [
      set color blue

      set territory pathces-in-territory patch 15 15 
      move-to one-of territory 
      ]


end

to-report pathces-in-territory [Center ]
  let ptr []
  ask Center [set ptr patches in-radius 5]
  report ptr
end

您也可以这样操作:

breed [animals animal]
animals-own [territory]
to setup  
  clear-all
    create-animals number-of-animals / 2  
    [
      set color red
    set territory pathces-in-territory patch 10 10 5
      move-to one-of territory 
      ]


   create-animals number-of-animals / 2  
    [
      set color blue

      set territory pathces-in-territory patch 15 15 10
      move-to one-of territory 
      ]


end

to-report pathces-in-territory [Center rd]
  let ptr []
  ask Center [set ptr patches in-radius rd]
  report ptr
end

因为我喜欢示例;)这是另一个示例,您也可以更改每个区域的pcolor:

since I like examples ;) this is another one which you can change the pcolor of each territory as well :

to-report pathces-in-territory [Center rd c]
  let ptr []
  ask Center [set ptr patches in-radius rd 
    ask  patches in-radius rd [set pcolor c]
    ]
  report ptr
end

,您可以这样调用函数:set territory pathces-in-territory patch 10 6 15 blue *更新

and you can call the function like this : set territory pathces-in-territory patch 10 6 15 blue *Update

我应该稍后再使用netlogo进行检查

I should check it with netlogo later

create-animals number-of-animals  
        [
          set color blue
          move-to one-of patches with [not any? animals-here]
          set territory patches in-radius 5 

          ]

如果要为每只动物定义区域,可以检查半径范围内是否没有乌龟超过该区域(例如5),然后将区域设置为乌龟周围的斑块

In case you want the territory to be defined for each individual animal you can check if there is no turtle in radius more that the territory for example 5 and then set the territory to patches around the turtle

   create-animals number-of-animals / 2  
    [

      move-to one-of patches with [not any? animals in-radius 5]
      set territory pathces-in-territory patch-here 2
      let h who
      ask territory [set pcolor h + 10 ] ; just for visual clarification 
      move-to one-of territory 
      ]

这篇关于NetLogo中基于区域大小的间隔代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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