【问题标题】:creating a specific path in Netlogo for turtles to follow在 Netlogo 中为海龟创建一条特定路径
【发布时间】:2017-03-31 00:42:54
【问题描述】:

我正在创建一个关于动物园的 Netlogo 模型。我需要我的动物园客人(多只海龟)沿着从动物园入口处开始的圆形路径每 24 次(在我的模型中 1 次为 1 小时)。它必须在容纳动物的笼子周围移动,因为我不能让我的客人进入动物区。路径不一定要快或最短,我只需要乌龟不要偏离它。我宁愿不使用 GIS 来创建路径。

我的世界的尺寸在两个方向上都是 -30 到 30 并且不会环绕。

笼子的下落描述如下:

patches-own [ tigerhabitat?
              flamingohabitat?
              monkeyhabitat?
              hippohabitat?
              giraffehabitat?
            ]

to create-habitats
  ask patches with [ pxcor < -12 and pycor > 23 ]
  [ set tigerhabitat? true
    set pcolor green ]

  ask patches with [ pxcor > 20 and pycor > 20 ]
  [ set hippohabitat? true
    set pcolor blue ]

  ask patches with [ pxcor > 18 and pycor < 15 and -1 < pycor ]
  [ set flamingohabitat? true
    set pcolor 96 ]

  ask patches with [ pxcor > -10 and pxcor < 10 and pycor < 10 and -10 < pycor ]
  [ set monkeyhabitat? true
    set pcolor green ]

  ask patches with [ pxcor < -12 and pycor < -20 ]
  [ set giraffehabitat? true
    set pcolor 67 ]

end

【问题讨论】:

  • 客人只需要沿路径移动一个方向吗?
  • 他们可以向一个方向移动(向前)。
  • 您希望他们遵循的路径在哪里?当我create-habitats 时,我确实看到了笼子;您能否详细说明您尝试过的内容以及为什么它没有按照您的意愿进行操作?如果您只需要知道从哪里开始,也许可以查看模型库中包含的一些模型。例如,Surface Walking 2D、Wall Follow 示例或 Look Ahead 模型。
  • 我不知道如何让我的龟品种之一,动物园的客人,不要进笼子。我没有尝试过任何事情,因为我不知道该怎么做。也许为动物园的客人制定一条严格的路径,绕着笼子走。

标签: path netlogo


【解决方案1】:

Paula- 从你的评论中我想我明白了一点,谢谢。控制海龟移动位置的一种简单方法是使用逻辑运算符排除它们在行走时“考虑”的补丁。对于您想要的基本(非路径)版本,您可以告诉海龟它们只能在不是笼子的补丁上移动。您可以设置一个仅限补丁的变量,明确说明补丁是否被笼子,但在上面的示例中,所有非笼子补丁都是黑色的 - 您可以使用它来告诉海龟他们应该只走上一条路径,如果它是黑色的。例如,您可以将以下过程添加到您的代码中:

to setup
  ca
  reset-ticks
  crt 10 [
    setxy -25 0
  ]
  create-habitats
end


to go
  exclude-cage-walk
  tick
end


to exclude-cage-walk
  ask turtles [
    rt random 30 - 15
    let target one-of patches in-cone 1.5 180 with [ pcolor = black ]
    if target != nobody [
      face target
      move-to target
    ]
  ]
end

可以看到,每只海龟在向前移动之前,都会评估它为move-to 选择的补丁是否为黑色,如果不是黑色,则海龟不会移动到那里。当然,你必须修改它以满足你的需要,让海龟在单向循环中行走,但这是一种限制海龟运动的简单方法。

【讨论】:

    猜你喜欢
    • 2016-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多