我需要解决以下问题的帮助。我有位于3个不同区域A,B,C的海龟。它们有一些属性
turtle-own[place-to-go]
patch-own[n-of-empty-places]
海龟移动到一个贴片,从一个位置上选择较大数字的位置[n of go在C]中的B n空地中的空地。
我想知道的是如何在每个动作后更新空地。例如,如果第一只乌龟前往A区域,则由于A中的N空点是列表中最大的数字,因此第二乌龟将从[n of Emply-patches a a a in -1 在c]中的b n of b n of thempatches。
有帮助吗?
I need help with the following problem. I have turtles located in 3 different zones A, B, C. They have some properties
turtle-own[place-to-go]
patch-own[n-of-empty-places]
Turtles move to one patch selecting the larger number from a list of place-to-go [n-of-empty-places in A n-of-empty-places in B n-of-empty-places in C].
What I would like to know is how to update the n-of-empty-places after each movement. For example, if the first turtle heads to area A, since n-of-empty-patches in A is the largest number in the list, the second turtle will select from a list that is [n-of-empty-patches in A -1 n-of-empty-patches in B n-of-empty-patches in C].
Any help?
发布评论
评论(1)
我看到您正在尝试使用列表来存储所有区域的空缺数量。附带说明,替代方案是使用3个数字变量而不是列表。无论如何,您应该注意的是,您描述的列表不是 一个补丁变量。相反,它是一个全球变量,因为世界各地的所有实体都可以访问。
这是一个建议:
我们假设
n of-applace-places
分别是与区域A,B和C相关的3个项目的列表。我们假设每个补丁的区域都在代码中分配为“ A”,“ B”或“ C”之一。
然后,在代码的主要功能中,我们可以要求最近移动的乌龟根据其新补丁的区域更新全局变量 。假设这只乌龟称为
Turtle-X
。请注意,我们可以要求一只乌龟告诉我们它站在的补丁的特性。另外,假设辅助变量Zone-Index
之前已经声明了:我建议您查找
iteg> item
,replace-Item
和position> positi /code>在netlogo dictionary()。
祝你好运
I see you are trying to use a list to store numbers of vacancies of all zones. As a side note, an alternative would be to use 3 numeric variables instead of the list. Anyway, what you should note is that the list you described is not a patches-own variable. Rather, it is a global variable, because it is accessible to all entities everywhere.
Here is a suggestion:
We assume
n-of-empty-places
to be a list with 3 items associated with zones A, B and C, respectively.We assume that the zone of each patch is assigned in the code to be one of "A", "B" or "C".
Then in the main function of the code we can ask a recently moved turtle to update the global variable
n-of-empty-places
according to the zone of its new patch. Suppose this turtle is calledturtle-x
. Note that we can ask a turtle to tell us the properties of the patch it is standing on. Also suppose the auxiliary variablezone-index
has been declared before:I suggest you look up
item
,replace-item
andposition
in NetLogo dictionary (http://ccl.northwestern.edu/netlogo/docs/index2.html).Good luck