這僅僅是一些代碼,讓你開始,有幾個方法可以做到你需要什麼,這只是其中之一。在這個有兩個品種,相機品種(你可能不需要使用一個品種,你可以問一些補丁設置一個變量真正的使他們相機點,然後他們可以有一個記錄),相機點記錄蜱和動物這是通過在半徑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
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
馬上工作吧!謝謝! – user2359494
@ user2359494可以請您提供完整的模型給我,我想延長它,請發送到我的電子郵件:)我的電子郵件:[email protected]在先感謝#look有趣 –