Netlogo:如何在上一只龟死后找到最近的海龟

时间:2016-03-02 00:12:31

标签: 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]]
  ]]

问题是乌龟死亡时的蜱虫,死龟最近的斑块在相同的蜱虫中找不到下一个最近的乌龟。

我有另一个子例程定义如下,它抛出一个错误,因为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'

如何避免这个错误,要求补丁选择他们最近的乌龟在他们的老乌龟死亡的同一个蜱中。

感谢任何帮助。感谢

1 个答案:

答案 0 :(得分:1)

这会有用吗?我刚刚移动了括号,以便die完成,然后找到

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]]