【问题标题】:How to draw shapes outside the big circle shape - netlogo如何在大圆圈之外绘制形状 - netlogo
【发布时间】:2018-07-23 00:41:31
【问题描述】:
我想画一个大圆圈,在它外面画 50 个小圆圈
breed [largecircle lc]
breed [smallcircke sc]
ask patches with [(pxcor > min-pxcor) and
(pxcor < (max-pxcor))]
[ set pcolor blue]
;cteate turtle / draw circle/ and make the circle to be in a drawing area (patches)
create-largecircle 1 [
set shape "circle"
set color green
setxy 0 0
set size 10
stamp
die
]
create-smallcircle 50 [
set shape "circle"
setxy random-xcor random-ycor;randomize
move-to one-of patches with [pcolor = blue ]
]
它不起作用。在大圆圈区域内仍然会生成圆圈
有什么想法可以解决这个要求吗?
【问题讨论】:
标签:
netlogo
shape
turtle-graphics
【解决方案1】:
您的方法不起作用,因为您没有修改景观中的任何 pcolors 补丁。 stamp 命令只留下大圆海龟的图像,但下面的 pcolors 仍然保持蓝色。因此,即使在大圆的标记区域内,您的小圆仍然可以移动。
要解决这个问题,您需要一种不同的方法。 NetLogo 中的海龟形状对于生成模型的视觉输出很有用。但是不可能识别出被某种乌龟形状覆盖的斑块。尽管海龟的视觉形状可以覆盖多个补丁,但它的位置仍然仅限于一个特定的补丁。
很难在不知道您确切计划对模型做什么的情况下推荐一种方法。但是,这是一个接近您提供的代码示例的解决方案:
breed [smallcircle sc]
globals [largecircle]
to setup
ca
ask patches with [(pxcor > min-pxcor) and (pxcor < (max-pxcor))][
set pcolor blue
]
;store patches within radius of center patch as global
ask patch 0 0 [
set largecircle patches in-radius (10 / 2)
]
;set color of largecircle patches green
ask largecircle [
set pcolor green
]
;create small circles and move to random location outside largecircle
create-smallcircle 50 [
set shape "circle"
move-to one-of patches with [not member? self largecircle]
]
end
我删除了 largecircle 品种,而是创建了一个全局变量 largecircle。
然后通过询问中心补丁创建大圆,识别特定半径内的所有补丁并将这些补丁存储在全局变量largecircle中。我们现在可以使用这个 patch-set 来设置 largecircle-patches 的 pcolor 或控制小圆圈的移动。