在NetLogo中创建虚拟陷阱

时间:2014-01-14 21:01:34

标签: netlogo

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

enter image description here

1 个答案:

答案 0 :(得分:3)

这只是一些让你入门的代码,有几种方法可以做你需要的,这只是其中之一。在这一个有两个品种,相机品种(你可能不需要使用一个品种,你可以要求一些补丁设置一个变量真实,使他们成为相机点,然后他们可以有一个记录),相机点记录刻度和动物它在半径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 [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