我下载了修改随机集群代码生成使用米林的版本中的NetLogo建模公地修改后的随机集群方式的中性景观模型。当我点击“生成景观”按钮,在代码中的“填充景观”过程使“命名没有?已经被定义”的错误。
当我创建的连接界面图像,并试图运行,下面的代码毗邻。这个问题似乎在“事件”报告功能来进行相关的问号。如预期的减少功能无法正常工作。是否有变通方法吗?见界面,然后在下面的代码:
ifelse ( any? neighbours with [ cluster != nobody ] ) ;; check if there are any assigned patches in neighbourhood
[
let covers []
ask neighbours with [ cluster != nobody ]
[
set covers fput cover covers ;;ask neighbours to add their covers to the list
]
let unique-covers remove-duplicates covers ;;create a list of unique covers
let max-cover-count -1 ;the number of neighbours with the maximum cover
let max-cover -1 ;the maximum cover
ifelse(length unique-covers > 1)
[
;if there is more than one unique-cover
foreach unique-covers ;for each of the unique covers
[
let occ occurrences ? covers ;count how many neighbours had this cover
ifelse(occ > max-cover-count) ;if the count is greater than the current maximum count
[
set max-cover ? ;set this as the dominant cover
set max-cover-count occ ;update the current maximum count
;---------------
to-report occurrences [x the-list]
report reduce
[ifelse-value (?2 = x) [?1 + 1] [?1]] (fput 0 the-list)
end
;---------------
该代码是假设生成使用修改后的随机簇方法通过绍拉和Martinez的-文澜(2000)开发了一种中性景观模型。但是,错误“没有命名?已经被定义”从平稳运行错误的代码。期待的想法...
布莱恩的回答(第一个过程)和的NetLogo词典(第二个过程)的组合为您提供了以下内容。评论表明新位。未经测试。
ifelse ( any? neighbours with [ cluster != nobody ] )
[ let covers []
ask neighbours with [ cluster != nobody ]
[ set covers fput cover covers
]
let unique-covers remove-duplicates covers
let max-cover-count - 1 ; added a space around subtraction
let max-cover - 1 ; more spacing
ifelse(length unique-covers > 1)
[ foreach unique-covers
[ this-cover -> ; here's the new bit, calling ? 'this-cover'
let occ occurrences this-cover covers ; passes to the occurrences procedure
ifelse(occ > max-cover-count)
[ set max-cover this-cover ; using the name this-cover again
set max-cover-count occ
而对于出现,你可以直接从词典的NetLogo例如reduce
走程序
to-report occurrences [#x #the-list]
report reduce
[ [occurrence-count next-item] -> ifelse-value (next-item = #x)
[occurrence-count + 1] [occurrence-count] ] (fput 0 #the-list)
end
从5.x的的NetLogo老?
语法与在的NetLogo 6.请参阅->
新https://ccl.northwestern.edu/netlogo/docs/programming.html#anonymous-procedures语法替换
因此,例如,在5的NetLogo,你可以这样写:
foreach [0 1 2 3] [
print ?
]
在6的NetLogo,你写的:
foreach [0 1 2 3] [ x ->
print x
]