Netlogo 乌龟跳过特定补丁

Netlogo turtle skips specific patch

我正在尝试指示海龟访问所有绿色斑块。

有一个我无法理解的行为:如果原点的位置 = 中心(请参见带有 0,0 蓝色的屏幕截图),则始终避免使用补丁 0,0,如果原点位置 = 角落。

这是为什么?我在这里犯了什么错误?

;;==========================================================
globals [
  memory
  target
]
patches-own [visit-counter]

;;==========================================================
to setup
  ca
  resize-world -6 6 -6 6
  set-patch-size 40
  create-turtles 1 [
    set memory (list patch-here)
    setxy random-pxcor random-pycor
    set size 1
    set color blue
  ]

  ask patches [if random 100 < 40 [set pcolor green]]
  ask patch 0 0 [set pcolor green]

  ask patches [set visit-counter 0]  
  reset-ticks
end

;;==============================================

to go

  ask turtles [choose-target]
  tick
  if ticks > 500 [stop]
end

;;==============================================
to choose-target
  pd

  ;; set of unvisited patches
  let unvisited patches with [not member? self [memory] of myself]

  ;; set of green patches that are not visited
  let targets patches with [(member? self unvisited) and (pcolor = green)]

  ;; select target and move there
  set target one-of targets with-min [distance myself]

  ifelse target != nobody [
    face target
    fd 1
    set visit-counter (visit-counter + 1)
    set memory lput patch-here memory
  ]
  [die
  ]
end

当您初始化变量 'memory' 时,您有 set memory (list patch-here)。那时,乌龟坐在 patch 0 0 上,所以原始补丁在内存中。您用于查找目标的代码排除了内存中已有的目标 let unvisited patches with [not member? self [memory] of myself]。因此,它没有资格被选为目标。