包含NOBODY作为其实体之一的列表

时间:2017-02-28 18:17:20

标签: list netlogo agentset

我的代码中有一个子路由,要求每个补丁选择最接近的&基于某些条件的最远的乌龟。经过几次滴答后我一直收到这个错误

OF expected input to be a turtle agentset or turtle but got NOBODY instead.
error while patch 0 30 running OF
  called by procedure UPDATE-SUPPORT
  called by procedure GO
  called by Button 'Go'

还有另外两个例程,其中龟死亡或出生,这取决于测量的一些其他指标。我无法调试代码,但到目前为止我想到的是它发生在乌龟死亡或出生后。

以下是最接近&的代码。每个蜱都分配最远的海龟。

to update-support    
  ask patches [ 
    let old-total sum [my-old-size] of parties
    set f-party []
    set h-party []

    set party-list (sort parties)
    set voteshare-list n-values length(party-list) [ (([my-old-size] of party ? ) + 1 ) / ( old-total + 1 ) ] 
    set party-citizen-dist n-values length(party-list) [ ( distance party ? ) ^ 2 ]    
    set f-list n-values length(party-list) [ ( ( 1 / ( item ? voteshare-list ) ) * ( item ? party-citizen-dist ) ) ] 
    set f-index position (min f-list) f-list    
    set h-list n-values length(party-list) [ ( ( item ? voteshare-list ) * ( item ? party-citizen-dist ) ) ]
    set h-index position (max h-list) h-list

    set f ((-1) * (min f-list))
    set h max h-list

    set f-party lput item f-index party-list f-party 
    set h-party lput item h-index party-list h-party
    set closest-party first f-party
    set farthest-party first h-party
    ]

在乌龟死亡之后,当我检查了抛出错误的补丁时,我发现单词nobody作为列表中的元素。在上面的代码

中创建voteshare-list时,错误会突出显示在Party ?部分

当我检查抛出错误的补丁时,派对列表是当前所有参与方排序的列表,显示:

Party-list: [(party 0) nobody (party 2)]

我的f-party列表只有[(nobody)]

有没有人遇到这种情况。?

以下是death&生育常规:

to party-death
   ask parties [if (fitness < survival-threshold and count parties > 2)
       [  die
       ] update-support
]

to party-birth
  ifelse (endogenous-birth? = true)
    [ ask one-of patches with [distancexy 0 0 < 30]
      [ if (random-float 1 < (kpi * 1000)) [sprout-parties 1 [initialize-party] ]]
    [ create-parties 1 [set heading random-float 360 jump random-float 30 initialize-party] ]
        update-support

end

0 个答案:

没有答案