如何在所有较高的邻居补丁中随机选择而不是最高邻居补丁? 我想删除(如果高程> = [海拔]最大一个邻居[海拔] [停止]) 并在[移动到一个邻居[停止]]
中放置“[停止]”to move ; a turtle procedure
if elevation >= [elevation] of max-one-of neighbors [elevation] [stop]
ifelse random-float 1 < q
[uphill elevation]
[move-to one-of neighbors]
end
答案 0 :(得分:1)
exists?
从代理集中随机选择代理,one-of
创建满足条件的代理的代理集。您还需要测试至少有一个位置要去。选择看起来像这样(确定阈值条件):
with
如果您想要在较高的邻居中进行选择,无论他们是否高于某个阈值,您都需要to move-up ; a turtle procedure
let candidates neighbors with [elevation >= <thresholdhold condition> ]
if any? candidates [ move-to one-of candidates]
end
。看起来这样选择3个最高之一:
max-n-of
答案 1 :(得分:1)
; The butterfly move procedure in turtle context
to move ; a turtle procedure
if elevation >= [elevation] of max-one-of neighbors [elevation] [stop]
; Decide whether to move uphill deterministically with probability q
ifelse random-float 1 < q
[ uphill elevation ] ; move uphill
[ move-to one-of neighbors ] ; otherwise move randomly
set patches-visited patches-visited + 1
end