Ming
Ming

Reputation: 215

How to sum plabel value?

I have created a NetLogo world. Agents can visit green patches, and plabel will show the visit times on each green patch. It works now. However, how could I sum all visits of each green patch after simulation? Something should be like:

to count-number

   ask patches [

      if plabel > 0 and pcolor = green and pycor >= -2 [

      show sum [plabel] of patches
     ]
   ]

end

Thanks.

Upvotes: 1

Views: 173

Answers (1)

drstein
drstein

Reputation: 1113

Try this:

 to count-number
  show sum [plabel] of patches with [ plabel > 0 and pcolor = green and pycor >= -2]
 end

Your code ask to every patch to print the sum of the labels of every patch but you need this to be done just once.

The plabel > 0 part is also useless since a patch with plabel = 0 will add 0 to the sum.

Upvotes: 3

Related Questions