2016-07-07 79 views
0

我無法找到一種方法來解決這個問題......我有海龜創建一個社交網絡(我使用無向鏈接)。Netlogo - 網絡問題

代理有許多變量,其中「y」和「ro」。我想知道的是與海龜相連的海龜的平均[ro]與[y < 1] ...有沒有辦法?

在實踐中...下面的公式

mean [ro] of turtles with [link-neighbor? turtle n]

我想,而不是turtle n代理設置turtles with [y < 1] ...是有辦法嗎?

謝謝!

回答

3
turtles-own [y ro] 

to test 
    ca 
    crt 50 [ 
    set y random-float 2 
    set ro one-of [1 2] 
    ] 
    ask turtles [ 
    create-links-with n-of 5 other turtles 
    ] 
    show mean [ro] of (turtles with [has-poor-neighbor]) 
end 

to-report has-poor-neighbor ;turtle proc 
    report any? link-neighbors with [y < 1] 
end