Netlogo:如何让补丁在前一只海龟死后找到最近的海龟

Netlogo:如何让补丁在前一只海龟死后找到最近的海龟,netlogo,turtle-graphics,Netlogo,Turtle Graphics,我有一套条件,当遇到乌龟就会死去。当一只海龟死亡时,我想让补丁找到他们最近的新海龟。我已经编写了以下代码 to party-death ask parties [ if ( my-size = 0 and count parties > 2) [ die ask patches [set closest-party min-one-of parties [distance myself]] ]] 问题是海龟死亡的蜱虫,死亡海龟最近的补丁在同一蜱虫中找不到下一个最近的海龟 我有另

我有一套条件,当遇到乌龟就会死去。当一只海龟死亡时,我想让补丁找到他们最近的新海龟。我已经编写了以下代码

to party-death
  ask parties [ if ( my-size = 0 and count parties > 2) 
[ die ask patches [set closest-party min-one-of parties [distance myself]]
  ]]
问题是海龟死亡的蜱虫,死亡海龟最近的补丁在同一蜱虫中找不到下一个最近的海龟

我有另一个子例程,定义如下,它抛出了一个错误,因为agentset中一个补丁最接近的海龟已经死了:

to citizen-comparison
 let voter-patches patches with [votes-with-benefit != 0]
 let nonvoter-patches patches with [votes-with-benefit = 0]
 ask voter-patches [ set voter-peccentricity [eccentricity] of closest-party]
 ask nonvoter-patches [ set nonvoter-peccentricity [eccentricity] of closest-party]

That party is dead.
error while patch 0 32 running OF
  called by procedure CITIZEN-COMPARISON
  called by procedure ELECTION
  called by procedure GO
  called by Button 'Go once'
如何避免这个错误,请补丁在他们的老海龟死亡的同一个蜱中选择他们的新海龟


谢谢你的帮助。谢谢这行吗?我刚刚移动了括号,以便完成
模具
,然后查找

to party-death
  ask parties [ if ( my-size = 0 and count parties > 2) [ die ] ]
  ask patches [set closest-party min-one-of parties [distance myself]]

它起作用了。我记得我试过,但那时候没用。不过,谢谢你的帮助。