使用带有 max-one-of 的命令 move-to 并出现错误:MOVE-TO expected input to be an agent but got NOBODY instead

Using the command move-to with max-one-of and the error appears: MOVE-TO expected input to be an agent but got NOBODY instead

我是 NetLogo 的新手,我有一个很基础的问题。但是,我并没有克服困难。

如果有人能帮助我克服这个困难,我将不胜感激。

我想从发现海龟的补丁中考虑8个相邻的单元格以寻找最高的pveg值。如果它具有同样高的值,则随机选择其中的 1 个。在找到邻居的最高pveg值后,乌龟就去了那里。

我正在使用命令:max-one-of。我认为这符合我的目的。但是,我犯了一些语法错误,显示以下错误:MOVE-TO expected input to be an agent but got NOBODY instead.

提前致谢

extensions [ gis ]
globals [ veg ]       
patches-own [pveg]

to setup
  clear-all
  reset-ticks
  setup-patches
  crt 1 [
   ask neighbors [ set pcolor blue ]
   set color black
  ]
 
end


to setup-patches
end

    
to go
  ask turtles [neighboring]
end

to neighboring
let my-neighWith-pveg [ neighbors with [pveg > 0.2] ]of patch-here   
ifelse neighWith-pveg = 0 
[  ] 

[ move-to max-one-of patches [my-neighWith-pveg] set pcolor red ;;ERROR HERE
    ]  
end



 

NetLogo 字典说,max-one-of 需要一个代理集和一个报告者作为输入:

max-one-of agentset [reporter]

在您的代码中,您使用了两个代理集:turtlesmy-neighWith-pveg

因为你想从邻居(而不是所有的海龟)中选择高pveg,你可以写:

max-one-of my-neighWith-pveg [pveg]