如何随机选择netlogo中海拔较高的邻居补丁 [英] how to randomly select a neighbor patch that has a higher elevation in netlogo

查看:171
本文介绍了如何随机选择netlogo中海拔较高的邻居补丁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在所有邻居补丁中随机选择而不是最高邻居补丁? 我正在考虑删除(如果海拔> = [最大一个邻居的[海拔] [海拔] [停止])) 并将"[stop]"放置到[移动到一个邻居[stop]]

how to randomly select among all the neighbour patches that are higher instead of the highest neighbour patch? I was thinking to remove (if elevation >= [elevation] of max-one-of neighbors [elevation] [stop]) and place "[stop]" in [move-to-one-of neighbors [stop]]

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

推荐答案

one-of从代理集中随机选择一个代理,而with创建满足条件的那些代理的代理集.您还需要测试至少要去一个位置.选择看起来像这样(要确定阈值条件):

one-of randomly selects an agent from the agentset and with creates an agentset of those agents satisfying the condition. You will also need to test that there is at least one location to go to. The selection would look like this (with threshold condition to be determined):

to move-up ; a turtle procedure
  let candidates neighbors with [elevation >= <thresholdhold condition> ]
  if any? candidates [ move-to one-of candidates]
end

如果您想在较高的邻居中进行选择,而不管它们是否高于某个阈值,则需要max-n-of.看起来是这样,选择3个最高的之一:

If you are instead wanting to choose amongst the higher neighbours regardless of whether they are higher than some threshold, you want max-n-of. Looks like this to choose one of the 3 highest:

to move-up
  move-to one-of max-n-of 3 neighbors [elevation]
end

这篇关于如何随机选择netlogo中海拔较高的邻居补丁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆