2016-08-05 72 views

回答

2
globals [ref-patch av-dist] 

to setup 
    ca 
    set av-dist mean [distance patch 3 -3] of patches 
    demo 
end 

to demo 
    ask patches [ 
    if distance patch 3 -3 < av-dist [ 
     set pcolor red 
    ] 
    ] 
end 
+0

'ref-patch' global未使用。 –

0

我想我會把一切都在一個補丁記者是這樣的:

to-report closer-than-average? report distance patch 3 -3 < mean [distance patch -3] of patches end

然後你可以

ask one-of patches [show closer-than-average?]

ask patches with [closer-than-average?] [set pcolor blue]