Netlogo 我如何解决错误(你不能在补丁上下文中使用my_uu区域,它只是一只乌龟)?

Netlogo 我如何解决错误(你不能在补丁上下文中使用my_uu区域,它只是一只乌龟)?,netlogo,rnetlogo,Netlogo,Rnetlogo,我希望海龟们回到他们的区域,如果我以前定义过的批次。问题是我出错了 you can not use my_ area in a patch context, it is a turtle-only 按钮是 to back_from_event ask turtles with [ area = 1 ] [ move-to one-of patches with [ (not any? other turtles-here) and ( area = my_area ) ] ] e

我希望海龟们回到他们的区域,如果我以前定义过的批次。问题是我出错了

you can not use my_ area in a patch context, it is a turtle-only 
按钮是

to back_from_event

  ask turtles with [ area = 1 ]  [ move-to one-of patches with [ (not any? other turtles-here) and ( area = my_area )  ] ]

end
补丁定义如下,海龟在区域2、3、4、5,并移动到区域1,我需要它们再次返回到这些区域:

to define_areas

  ask patches with [ (pxcor > -3) and (pxcor < 3) and (pycor > -3) and (pycor < 3) ] [  set pcolor white set area 1    ]
  ask patches with [ (pxcor > 5 ) and (pxcor < 16 ) and (pycor > 4) and (pycor < 16) ] [  set pcolor white set area 2     ]
  ask patches with [ (pxcor < -5 ) and (pxcor > -16 ) and (pycor > 4) and (pycor < 16) ] [  set pcolor white set area 3    ]
   ask patches with [ (pxcor < -5 ) and (pxcor > -16 ) and (pycor < -4) and (pycor > -16) ] [  set pcolor white set area 4    ]
  ask patches with [ (pxcor > 5 ) and (pxcor < 16 ) and (pycor < -4) and (pycor > -16) ] [  set pcolor white set area 5   ]

end

好的,这个问题和你之前的问题是一样的。请尝试理解答案,而不是简单地复制代码。否则,你会继续问同样的问题

“area”作为面片变量,“my_area”作为turtle变量

你需要意识到的是,要修补的海龟是独一无二的,因为海龟一次只能在一个地方。因此,海龟可以访问它所在的补丁所拥有的变量,而无需指定补丁。这样的代码是可以的:

ask turtles with [area = 1] [ ]
这是因为它相当于:

ask turtles with [ [area] of patch-here = 1] [ ]
但是,修补程序无法访问海龟拥有的变量,因为同一修补程序上可能有多个海龟。例如,如果您要求一个补丁将其pcolor设置为color,而补丁上有一只红海龟和一只蓝海龟,它如何知道选择哪种颜色

您的错误表明您不能在补丁上下文中使用my_区域,它只是一只海龟。也就是说,您试图让补丁使用my_area变量,但该变量归海龟所有。所以你没有告诉它从哪只乌龟那里得到我的地盘

这就是你所拥有的:

to back_from_event
  ask turtles with [ area = 1 ]
  [ move-to one-of patches with [(not any? other turtles-here) and (area = my_area)] 
  ]
end
我假设你想让补丁的面积和海龟的my_面积一样。这就是我的目的


请同时提供您的turtles own和patches own声明Assure patches own[area]turtles own[my_area culture child_2_color child_1_color]设置为:要设置ca定义_areas create_parent create_children ask turtles[在此设置补丁的my_area[area]ask turtles[set culture[]重复文化特征[ask turtles[set culture fput random traits_per_features+1 culture]]重置勾号结束你应该编辑你的问题,而不是在评论中添加代码。看看你的评论,代码显然是不可读的。
to back_from_event
  ask turtles with [ area = 1 ]
  [ move-to one-of patches with [(not any? other turtles-here) and (area = [my_area] of myself)] 
  ]
end