如何在 max-one-of 中包含更多品种并绘制找到的最高值及其分布

How to include more breeds in max-one-of and plot the highest value found and its distribution

我正在使用列表来构建模型。我有三个品种,但其中只有两个有自己的列表,用于收集创建的项目(并且应该创建项目)。 我想 select 一只随机的乌龟,并在它的袋子里找到属性最高的物品。然后我想绘制属性及其分布如下:

plotxy attribute1 fun2

其中 attribute1ask link-neighbors 中定义的属性:

set attribute1 attribute1_b - m

fun2应该定义为set fun2 (1 - [attribute1]) where属性1应该是包中属性最高的'selected'项的属性。

因为我在这部分代码中涉及三个品种,分别是childreninfantstoy,但我想考虑只绘制由[生成的属性=19=]和infants,请问如何定义包中属性最高的玩具,然后childreninfants如何绘制。
从我之前的问题 绘图时出错:OF expected input to be a turtle agentset or turtle 我收到了这个答案:

set picked_toy max-one-of (children with [member? self bag]) [attribute1]

但在当前情况下,最大值不仅可以是 children,还可以是 infants。 我试着写:

set picked_toy max-one-of (children with [member? self bag] and infants with[member? self bag] [attribute1]

但我收到以下错误:

AND expected this input to be a TRUE/FALSE, but got an agentset instead

我是一个自学成才的人,我在网站上看了很多material,但有时我找不到我想找的东西。我犯了错误,很多错误,但这可能也是一种很好的学习方式(并记住避免重复相同的错误)。 我希望你能理解并尝试帮助我解决这个新问题。谢谢。

问题在于您正在使用关键字 and 组合两个代理集(儿童子集和婴儿子集),但 and 保留用于逻辑操作。为了组合两个代理集,我们使用 turtle-set 原语。

set picked_toy max-one-of ((turtle-set children with [member? self bag] infants with[member? self bag])) [attribute1]

turtle-set 周围的 () 是必需的,因为我们给它提供了不止一个参数。 (我没有看过您的其余代码,只看过这一行。)希望对您有所帮助。