netlogo多乌龟的品种变量

发布于 2025-01-28 14:46:39 字数 596 浏览 2 评论 0原文

我正忙于绘制一个组织治疗的儿童(Turtle Breed 2)的儿童人数(Turtle Breed 2)。这些组织拥有一个乌龟拥有的变量,称为儿童处理的,其中所有的孩子都在接受处理。

在“绘图更新命令”中,我现在有:

ask organizations [
  create-temporary-plot-pen (word who)
  set-plot-pen-color color
  plot [length children-treated]
]

但是,一条错误消息说

在这里期待一个数字,而不是列表或块

我尚不清楚该错误适用哪个位置。

有必要使此自动变速器,而不是手动不同的绘图笔,因为可以通过滑块调整组织的数量。

这就是我希望情节的样子:

I'm busy trying to plot the number of children (turtle breed 1) treated by an organisation (turtle breed 2). The organisations have a turtles-own variable called children-treated where all the children are stored which are being treated.

In the 'plot update commands' I now have:

ask organizations [
  create-temporary-plot-pen (word who)
  set-plot-pen-color color
  plot [length children-treated]
]

However, an error message says

Expected a number here, rather than a list or block

It is not clear to me to which place this error applies.

It is necessary to make this automatic, and not manually the different plot pens, as the number of organisations can be adjusted by a slider.

This is how I want the plot to look like:
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一直在等你来 2025-02-04 14:46:39

如您所见/code> is plot number ,没有方括号(在Netlogo中标识列表或命令块)。您的长度为儿童处理的是一个数字(我知道condry preated是一个列表),因此您无需将其包装在方括号中:

plot length children-treated

最多最多您可以使用括号以实现可读性:

plot (length children-treated)

As you can see here, the syntax for plot is plot number, without square brackets (that in NetLogo identify a list or a block of commands). Your length children-treated is a number (so I understand that children-treated is a list), so you don't need to enclose it in square brackets:

plot length children-treated

At most you can use parentheses for the purpose of readability:

plot (length children-treated)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文