用pycor要求补丁=发芽海龟的范围

时间:2019-12-16 20:17:07

标签: netlogo

一个。我正在尝试在netlogo中设置供应链结构。每层的元素(即DistributionCenters)具有相同的xcor,我希望它们在ycor上均匀间隔(请注意DistrubutionCenters的数量是可变的,并使用滑块导入)。我已经尝试了很多方法并得出以下想法,但这些补丁不会使海龟发芽


breed [Producers Producer]
breed [DistributionCenters DistributionCenter]

to setup

  clear-all

  set-default-shape DistributionCenters "house ranch"
  let DCR1 (- floor ( n_DistributionCenters / 2 ))
  let DCR2 (  floor ( n_DistributionCenters / 2 ))
  let DistRange (range DCR1 DCR2 1)
  ask patches with [ pxcor = 0 and pycor = DistRange][sprout-DistributionCenters 1]

1 个答案:

答案 0 :(得分:1)

您的问题是您要问数字(pycor)是否等于列表。这些是不同类型的数据。因此,您的示例等效于此完整模型(已打印出列表):

to testme
  clear-all
  let selected (range 0 15 3)
  print selected
  ask patches with [pxcor = 0 and pycor = selected] [set pcolor blue]
end

一种方法是分别使用foreachask适当的补丁遍历列表:

to testme2
  clear-all
  let selected (range 0 15 3)
  print selected
  foreach selected
  [ here -> ask patch 0 here [set pcolor blue]
  ]
end

或者,我认为这在概念上与您尝试执行的操作类似-它使用member?来测试列表的成员资格:

to testme3
  clear-all
  let selected (range 0 15 3)
  print selected
  ask patches with [pxcor = 0 and member? pycor selected] [set pcolor blue]
end