用 pycor 询问补丁 = 发芽海龟的范围



>one. 我正在尝试在Netlogo中建立供应链结构。 每一层(即分布中心(的元素具有相同的 xcor,我希望它们在 ycor 上均匀分布(请注意,DistributionCenter 的数量是可变的,并使用滑块导入(。 我尝试了很多方法,得出了以下想法,但补丁不会发芽海龟


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]

你的问题是你在问一个数字(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

一种方法是使用foreach循环访问列表并单独ask相应的修补程序:

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

最新更新