Reputation: 51
I am chasing my tail with this piece if code. Having rectified one error (with the help of stakoverflow) i now get another. The error reports "TASK expected 1 input, a reporter or task command" and highlights the word "task". I am not sure if it to do with the brackets?
;; 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 ]
Upvotes: 0
Views: 62
Reputation: 12580
I think you just want setup task [ random error-count ]
, so that you're passing the reporter block [ random error-count ]
to task
. So the whole thing would look like:
to setup-random
ask patches [
if (random-float 100.0) < init-errors
[ setup task [ random error-count ] ]
The above assumed that setup
was a procedure runnable by patches. If this is actually just a modification of the sandpile model in the models library, then you probably want:
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.
]
]
Upvotes: 2