这是一种方法:
您可以更改每种动物的中心补丁,并且可以设置您希望其领地重叠的程度。
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 的示例:
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
*Update
我应该稍后用 netlogo 检查一下
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),然后将领地设置为海龟周围的补丁
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
]