我试图选择owner
龟的status
小于myself
的邻居补丁。如果存在这种补丁,则myself
将其领土扩展到这些补丁并成为owner
。但我无法要求NetLogo确定相邻修补程序owner
的status
。我可以用owner
选择邻居,然后打印这些所有者的status
,但就是这样。任何帮助将非常感激。代码如下。NetLogo从补丁变量查询龟变量
breed [animals animal]
animals-own [ orig territory food status]
patches-own [ owner hsi]
to setup
clear-all
ask patches
[
set owner nobody
set hsi random 5
set pcolor scale-color (black) hsi 1 4
]
let $colors [red pink yellow blue orange brown gray violet sky lime]
ask n-of 10 patches
[
sprout-animals 1
[
set orig patch-here
set territory patch-set orig
set status random 4
set color item who $colors
set pcolor color
set owner self
pen-down
]
]
reset-ticks
end
to go
if all? animals [food >= 150] [ stop ]
if ticks = 50 [ stop ]
ask animals [ expand ]
tick
end
to expand
let neighborline no-patches
let pot-comp no-patches
if food < 150
[
ask territory
[
if any? neighbors with [owner = nobody]
[
set neighborline (patch-set neighborline neighbors with [owner = nobody]) ;this works fine.
]
if any? neighbors with [owner != nobody]
[
set pot-comp (patch-set pot-comp neighbors with [[status] of owner < [status] of myself]) ; this does not work. What am I doing wrong?
]
]
let target max-n-of 3 neighborline [hsi]
set territory (patch-set territory target) ; grow territory to 3 patches with no owners and highest HSI
ask territory
[
set owner myself
set pcolor [color] of myself
]
set food sum [hsi] of territory
]
end
谢谢Nicolas!我一直陷在这太久。现在我明白“我自己”是指错误的水平。 – user2359494