Netlogo 如何将面片移动到离原点较近的空面片?

Netlogo 如何将面片移动到离原点较近的空面片?,netlogo,Netlogo,我希望我的代码能够根据滑块中给出的海龟数量进行更多的压缩,我希望将其集中到原点。如果这是我的代码 to solid set color blue set xcor random sqrt number-of-particles - number-of-particles / 2 set ycor random sqrt number-of-particles - number-of-particles / 2 ifelse any? patches with [pcolor =

我希望我的代码能够根据滑块中给出的海龟数量进行更多的压缩,我希望将其集中到原点。如果这是我的代码

to solid
  set color blue
  set xcor random sqrt number-of-particles - number-of-particles / 2
  set ycor random sqrt number-of-particles - number-of-particles / 2
  ifelse any? patches with [pcolor = black and count turtles-here = 0]
  [move-to one-of patches with [pcolor = black and count turtles-here = 0]]
  [die]
end
我如何将其包括在内,以便海龟能够移动到离原点最近的空白区域?到目前为止我有

if number-of-particles < volume * volume
  [move-to one-of patches with [
如果粒子数<体积*体积
[移动到其中一个具有[
假设“原点”指的是补丁0,这里有一种方法:

to move-near-origin
  let free-patches patches with [pcolor = black and not any? turtles-here]
  ifelse any? free-patches [
    move-to min-one-of free-patches [ distance patch 0 0 ]
  ]
  [ die ]
end
两个关键部分是和


还请注意,我将
count turtles here=0
替换为
not any?turtles here
,这基本上做了相同的事情,但可读性更强。我还使用[pcolor=black and not any?turtles here]存储了
补丁
免费补丁
变量中,这样你就不必重复自己并测试所有补丁两次。

你有更多的上下文吗?这是关于什么的,什么语言等?语言是netlogo。抱歉,我忘了添加它!这是一张图片:我想让蓝色圆圈以原点为中心我很乐意。既然你是新来的,你可能想检查一下。