将 turtle-only 变量设置为补丁坐标

set turtle-only variable as patch coordinates

我正在创建一个模拟,其中入店行窃者瞄准商店(石灰补丁)并决定是否入店行窃。

我正在努力处理的代码是

set apprehended-here apprehended-here pxcor pycor of patch-here 

这是行不通的。我正在尝试将一个乌龟自己的变量设置为 store/s 的坐标,以便我可以告知以后的决定

(如果以前在这家商店逮捕过扒手,将会有警察介入)。

我的告知方式是否正确?

ask shoplifters [ if [pcolor] of patch-here = lime  and                       
perception-of-risk <= 60 and forever-deterred = 0          

[ifelse (random-float 1 < 0.98)  [                            
  set successful-shoplifts successful-shoplifts + 1 ]         

  [ifelse (random-float 1 < 0.05) [                            
    set successful-shoplifts successful-shoplifts + 0 ]        

    [ifelse (random-float 1 < 0.99 ) [                       
      set security-apprehension security-apprehension + 1 
      if professional = 0 and (random-float 1 < 0.97) [set forever-deterred 1]    
      set apprehended-here apprehended-here pxcor pycor of patch-here
      ]
      [set successful-shoplifts successful-shoplifts + 1 ]       

  ]]]]
end

部分是概念问题,部分是代码问题。概念上的问题是这样的——你是否希望小偷跟踪它被逮捕的所有补丁?如果是这样,那么小偷需要跟踪多个补丁。或者它只是最近被捕的地点?我想你想要所有的位置。

在这种情况下,存储位置的最佳方式是作为位置的 patch-set(在 NetLogo 字典中查找)。所以您想将新补丁添加到现有补丁集中。试试这个:

set apprehended-here (patch-set apprehended-here patch-here)

要实现此功能,您需要在首次创建商店扒手时分配一个空补丁集。当扒手被捕时,您还需要代码来确定补丁是否在补丁集中。那将是这样的:

if member? patch-here apprehended-here [ < punish > ]