How to set the patch variable as the number of turtles - here

I want to set the patch variable equal to the number of turtles on this patch.

I tried

ask for patches [set variableA (count turtles-here)]

when I do this, I get the error: "set the expected 2 inputs"

I tried using a workaround by setting the number of turtles as a patch

ask for patches [set plabel (count turtles-here)]

this code worked, but I need to do this for several variables, and when I tried to transfer the poster to a variable

request patches [set variableA plabel]

i get the error again: "SET awaiting 2 inputs"

any help is appreciated.

+4
source share
1 answer

, variableA ? , . , , :

patches-own [ variableA ]

to test
  ask patches [ set variableA (count turtles-here) ]
end

, , , , - variableA -, . :

to test
  ask patches [ set variableA (count turtles-here) ]
end

to-report variableA [ x ]
  report 0
end

... 2 .

+3

Source: https://habr.com/ru/post/1526878/


All Articles