我正试图让海龟在所有较高的邻居补丁中随机选择。我的代码让乌龟移动到最高的补丁,但我希望它随机完成。
我的代码:
to move
if elevation >= [elevation] of max-one-of neighbors[elevation]
[stop]
ifelse random-float 1 < q
[ uphill elevation ]
[ move-to one-of neighbors]
set patches-visited patches-visited + 1
end
答案 0 :(得分:1)
在一行
move-to one-of neighbors with [elevation > [elevation] of myself]]
在你的代码中它想要这个
to move
if elevation < [elevation] of max-one-of neighbors[elevation]
[
move-to one-of neighbors with [elevation > [elevation] of myself]]
set patches-visited patches-visited + 1
]
end