NetLogo - 沙堆 - 错误

NetLogo - Sandpile - Error

我正在用这段代码追我的尾巴。纠正了一个错误(在 stakoverflow 的帮助下)后,我现在得到了另一个错误。错误报告 "TASK expected 1 input, a reporter or task command" 并突出显示单词 "task"。我不确定这是否与括号有关?

;; 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 ]

我想你只是想要 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 是一个可由补丁运行的程序。如果这实际上只是模型库中沙堆模型的修改,那么你可能想要:

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.
     ]
   ]