Javier Sandoval
Javier Sandoval

Reputation: 507

Netlogo count patches with neighbors of specific color

How can I code to know how many patches are in my world that have yellow neighbors? I'm using the following line:

ask patches [ show count neighbors with [pcolor = yellow] ]

The result is a long list of each patch answering the question, but all that I need is the number of patches that fulfill the mentioned condition. Thanks for any help.

Upvotes: 4

Views: 2594

Answers (1)

Luke C
Luke C

Reputation: 10291

I think you want

print count patches with [ any? neighbors with [ pcolor = yellow ] ]

Upvotes: 8

Related Questions