Netlogo代码问题,海龟可以';无法在0,0处找到修补程序

Netlogo代码问题,海龟可以';无法在0,0处找到修补程序,netlogo,Netlogo,我正在尝试创建一个与本视频(1:29-1:45)相同类型的模拟 我认为一个实现无限循环的简单方法是让海龟面对0,0,然后寻找半径为90的空白区域(所以它们总是向右看) 我得到了错误代码 '从点(3,-6)到同一点没有定义航向。' 有人能用我的密码告诉我正确的方向吗 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; turtles-own [ faction ] to setup clear-all ask patches [ set

我正在尝试创建一个与本视频(1:29-1:45)相同类型的模拟

我认为一个实现无限循环的简单方法是让海龟面对0,0,然后寻找半径为90的空白区域(所以它们总是向右看)

我得到了错误代码

'从点(3,-6)到同一点没有定义航向。'

有人能用我的密码告诉我正确的方向吗

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


turtles-own [ faction ]

to setup
  clear-all

  ask patches [ set pcolor white ]
  set-patch-size 7
  resize-world min-pxcor max-pxcor min-pycor max-pycor 


  ask patch 0 0
   [ ask patches in-radius ( max-pxcor * .6) with [  random-float 100 < density ]
     [ sprout 1
         [
         set shape "circle"
         assign-factions
         set color faction-color
         set size 1 ] ] ]

   ask turtles-on patch 0 0 [ die ]

   reset-ticks
end

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to-report faction-color
   report red + faction * 30
end

to assign-factions
   let angle 360 / factions
   foreach n-values factions [?] [
    ask patch 0 0 [ 
      sprout 1 [
        set heading ? * angle
        ask turtles in-cone max-pxcor angle [ set faction ? + 1 ]
        die ] ] ]
end

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to go 

  ask turtles
  [ set heading (towards patch-at 0 0)  ; adjusts heading to point to centre  
    let empty-patches neighbors with [not any? turtles-here]
    if any? empty-patches in-radius 90
      [ let target one-of empty-patches
        face target
        move-to target ] 
  ]

end

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
<代码>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 乌龟自己的[派别] 设置 清除所有 询问补丁[设置pcolor白色] 设置补丁大小为7 调整世界最小pxcor最大pxcor最小pycor最大pycor 询问修补程序0 [使用[random float 100这是因为半径中的
可以。要解决此问题,只需更改线条即可

ask patches in-radius .....


go
过程中,您正在使用
设置标题(朝向0处的补丁)
,但会在与正在请求的海龟相对的位置提供补丁。因此,如果您在0 0处请求
补丁,则始终会得到海龟实际所在的补丁。并且朝向自己的方向未定义,因此会出现错误

patch 0 0
替换
patch 0 0
(使用绝对坐标)可以解决一半的问题:您询问的海龟仍然可能已经在
patch 0 0
。在这种情况下,您将得到与以前相同的错误


解决方案:替换
设置标题(朝向0处的补丁)
使用
面片0 0
。如果你要求面片面对你已经在的位置,原语不会崩溃。

我不认为在radius 90中要求空白面片
会达到你认为的效果。但我会让你自己找出那部分。你随时可以问另一个问题。。。
ask other patches in-radius .....