Netlogo : change patch color of one patch if orthogonal neighbors have the same color -



Netlogo : change patch color of one patch if orthogonal neighbors have the same color -

i'm new netlogo , need help.

i trying grow continuous patch of 1 color (green on black background). however, have black patch surrounded greenish patches. alter color of black patches green.

i tried :

ask patches [ if neighbors4 [pcolor = 55] [set pcolor 55] ]

but gives me error, does

ask patches [ if any? neighbors4 [pcolor = 55] [set pcolor 55] ]

here code works leave black patches surrounded greenish patches :

to setup clear-all set-patch-size 4 resize-world -50 50 -50 50 inquire patches[set pcolor black] grow-cell reset-ticks end grow-cell inquire patch 0 0 [ set pcolor 55 inquire neighbors [ set pcolor 55 ] ] repeat 45 [ inquire patches [pcolor = black] [ set pcolor [pcolor] of one-of neighbors4 ] ] end

here ugly/barely clever hack.

ask patches[ if mean [pcolor] of neighbors4 = green[set pcolor green] ]

or alternately

ask patches with[count neighbors4 with[pcolor = green] = 4][set pcolor green]

patch netlogo

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -