如果代码,我正在追逐我的尾巴。纠正了一个错误(在stakoverflow的帮助下)我现在得到另一个错误。错误报告“TASK预期1输入,记者或任务命令”并突出显示“任务”一词。我不确定它是否与括号有关?
;; The density of patches to be set with a random value is set using variable init-errors on interface.
;; Every patch uses a task which reports a random value.
;; The random value is set using variable error-count on interface
to setup-random
ask patches [
if (random-float 100.0) < init-errors
[ setup task ] [ random error-count ]
答案 0 :(得分:2)
我认为您只想要setup task [ random error-count ]
,以便将记者块[ random error-count ]
传递给task
。所以整个事情看起来像:
to setup-random
ask patches [
if (random-float 100.0) < init-errors
[ setup task [ random error-count ] ]
以上假设setup
是一个可以通过补丁运行的程序。如果这实际上只是对模型库中sandpile模型的修改,那么您可能需要:
to setup-random
setup task [
ifelse-value (random-float 100.0 < init-errors) [
random error-count
] [
0 ;; Or whatever you want your non-"error" patches to get.
]
]