Netlogo 如何在椭圆中随机播种海龟?

Netlogo how do I seed turtles randomly in an ellipse?

我是 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)/(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

非常感谢!

创建海龟时,您可以将每个海龟随机移动到 selected 蓝色补丁。

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

请注意,move-to 会将海龟定位在补丁的中心。所以 setxy 将它移动到同一块上的一组随机坐标。如果它们可以居中,您可以跳过该行。

或者,如果您需要海龟都在不同的补丁上,那么您可以随机 select n-of 个蓝色补丁并让每个 sprout 一只乌龟。