Netlogo如何在椭圆中随机播种海龟?
我是NetLogo的新手,我想在椭圆内随机播种海龟。 我在椭圆中设置了蓝色的补丁,在背景中设置了白色的补丁。 下一步,我想在椭圆上随机设置海龟,上面有蓝色的补丁。 我如何做到这一点Netlogo如何在椭圆中随机播种海龟?,netlogo,Netlogo,我是NetLogo的新手,我想在椭圆内随机播种海龟。 我在椭圆中设置了蓝色的补丁,在背景中设置了白色的补丁。 下一步,我想在椭圆上随机设置海龟,上面有蓝色的补丁。 我如何做到这一点 to setup clear-all setup-patches setup-turtles reset-ticks end to setup-patches ask patches [ ifelse (pxcor ^ 2)/(195.5 ^ 2) + (pycor ^ 2)
to setup
clear-all
setup-patches
setup-turtles
reset-ticks
end
to setup-patches
ask patches [
ifelse
(pxcor ^ 2)/(195.5 ^ 2) + (pycor ^ 2)/(49 ^ 2) < 1
[set pcolor blue]
[set pcolor white]
]
end
to setup-turtles
create-turtles 6
ask turtles [
set size 10
set shape "circle"
if pcolor = blue
[setxy random-xcor random-ycor]
]
end
非常感谢 创建海龟时,可以将每个海龟移动到随机选择的蓝色区域
to setup-turtles
let blue-patches patches with [pcolor = blue]
create-turtles 6
[ set size 10
set shape "circle"
move-to one-of blue-patches
setxy xcor - 0.5 + random-float 1 ycor - 0.5 + random-float 1
]
end
请注意,移动到将海龟定位在补丁的中心。因此,setxy将其移动到同一面片上的一组随机坐标。如果它们可以居中,你可以跳过那条线
或者,如果您需要海龟都在不同的补丁上,那么您可以随机选择n个蓝色补丁,让每个补丁发芽一只海龟。非常感谢您的帮助!我认为它可以让蓝色的补丁与[pcolor=blue]结合。