【问题标题】:Moving turtles to agentset of patches将海龟移动到补丁代理集
【发布时间】:2020-03-14 10:49:04
【问题描述】:

如果我选择一个代理集的补丁,例如:

<observer> let myset patches with [abs pxcor < (grid-size / 2) and abs pycor < (grid-size / 2)]
<observer> ask myset [print self]
(patch 1 -1)
(patch -1 -1)
(patch 0 0)
(patch 1 0)
(patch 0 1)
(patch 0 -1)
(patch 1 1)
(patch -1 1)
(patch -1 0)

如何将我所有的海龟(与我选择的补丁一样多,所以 9 个)每一个移动到不同的补丁?

我尝试了以下方法:

ask turtles [
    move-to one-of myset 
    ]

但是现在有可能不同的海龟在同一个补丁上。我怎样才能避免这种情况?

【问题讨论】:

    标签: netlogo patch agentset


    【解决方案1】:

    假设补丁上没有任何其他海龟,然后让他们选择一个空补丁(不确定语法是否完全正确,但类似):

    ask turtles [
        move-to one-of myset with [not any? turtles-here]
        ]
    

    【讨论】:

    • 非常感谢,这就是我要找的!超级简单,你可能猜到我是 Netlogo 的新手 ;-)
    猜你喜欢
    • 1970-01-01
    • 2020-07-09
    • 2016-03-26
    • 2020-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多