netlogo - 在 NetLogo 中创建虚拟陷阱

标签 netlogo

我有一个在景观中移动的动物 NetLogo 模型。我想将虚拟“相机陷阱”(使用红外光束拍摄动物照片的现场相机)随机放置在景观上,彼此之间保持一定的距离。然后,当其中一只动物在相机陷阱的一定半径内行走时,就会记录下蜱数和有关该动物的信息。请参阅下面的说明性示例。根据插图,我想报告与相机陷阱(星星)周围的浅蓝色区域相交的那些动物的蜱虫和动物信息。我不知道该怎么做。任何建议都会非常有帮助。谢谢。

enter image description here

最佳答案

这只是一些帮助您入门的代码,有几种方法可以满足您的需要,这只是其中之一。在这个中有两个品种,相机品种(您可能不需要使用品种,您可以要求几个补丁将变量设置为 true 以使它们成为相机点,然后它们可以有记录),相机点记录蜱虫和动物它以半径 2 传递(您也可以使用距离基元)

breed [Animals animal]
breed [Cameras Camera]
Cameras-own [records]

to setup
let Zone 2
  clear-all
  reset-ticks
  resize-world 0 20 0 20 
  set-patch-size 20
  set-default-shape animals "wolf"
  set-default-shape cameras "star"

create-Cameras 5 [
  set records []
  setxy random max-pxcor random max-pycor 
  set color white 
  ask patches in-radius Zone 
  [
    Set pcolor 88
    ]
  ]
Create-animals 10 [move-to one-of patches]
end



end
to go
ask animals
[
  animals-walk
  ]


tick  
end

to animals-walk
  rt random 10
  fd 1
  if any? cameras in-radius 2 [

    ask one-of cameras in-radius 2 [
      set records lput (list ticks myself) records
    ]]

end

enter image description here

  observer> ask camera 4 [ print records]
    [[0 (animal 10)] [0 (animal 11)] [1 (animal 10)] [1 (animal 6)] [2 (animal 10)] 
    [2 (animal 6)] [3 (animal 10)] [3 (animal 6)] [4 (animal 6)] [10 (animal 7)] 
    [11 (animal 7)] [12 (animal 7)] [13 (animal 7)]]

更新: 这个相机没有使用 Breed,而是使用了补丁:

    breed [Animals animal]

patches-own [records is-camera-point?]
Globals [Cameras]

    to setup
    let Zone 2
      clear-all
      reset-ticks
      resize-world 0 20 0 20 
      set-patch-size 20
      set-default-shape animals "wolf"
     setup-world

    Create-animals 10 [move-to one-of patches]
    end

    to setup-world
    ask patches [
      set pcolor white
      set records []
      set is-camera-point? false
    ]

    ask n-of 5 patches [
      set is-camera-point? true
      set records []

      set pcolor red]

    set Cameras patches with [is-camera-point?]
    end
    to go
    ask animals
    [
      animals-walk
      ]


    tick  
    end

    to animals-walk-with-Radius
      rt random 10
      fd 1
      if any? cameras in-radius 2 [

        ask one-of cameras in-radius 2 [
          set records lput (list ticks myself) records
        ]
        ]

    end
    to animals-walk ; with distance
      rt random 10
      fd 1
      if any? cameras with [distance myself < 2] [

        ask one-of cameras with [distance myself < 2] [
          set records lput (list ticks myself) records
        ]
        ]

    end

关于netlogo - 在 NetLogo 中创建虚拟陷阱,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21123954/

相关文章:

social-networking - NetLogo 创建固定数量链接的有效方法

list - NetLogo:如何使用引用相应列表的标准来过滤列表?

NetLogo:如何根据另一个向量中随机选择的值构建新向量?

netlogo - 海龟开始时的正态分布

netlogo - 更新 NetLogo 中的一些绘图

netlogo - 我什么时候可以将 NetLogo 值作为整数进行比较?

NetLogo:设置初始海龟数量,周围有空邻居?

netlogo - 在景观中添加斑 block 簇

netlogo - 没有名为 nw :clustering-coefficient has been defined 的内容

default-value - Netlogo - 乌龟变量的默认值