Libraries‎ > ‎Library‎ > ‎Miscellaneous‎ > ‎


BehaviourComposer: ignore everything before this.

Begin micro-behaviour:

Begin description:

Print patch colours into the NetLogo command center for Load patch colours to use.

End description

Print patch colours

Begin NetLogo code:

let x min-pxcor
let y min-pycor
let c [pcolor] of patch x y
let r 1
let patch-count count patches
print "["
while [y <= max-pycor]
      [set x x + 1
       if (x > max-pxcor) 
          [set y y + 1
           set x min-pxcor]
       if (y <= max-pycor)
          [if (c != [pcolor] of patch x y)
              [print (list r c)
               set r 0
               set c [pcolor] of patch x y]
          set r r + 1]]
print (list r c)
print "]"    

End NetLogo code

This prints out a list of run-length encoded changes in colour.

This is particularly useful for running models in NetLogo Web because it doesn't support NetLogo's import-pcolors and import-pcolors-rgb. The recommended usage is to import the colors, then run this behaviour. Note you typically will need to delay it to ensure this runs after import-pcolors. Copy  the output of this behaviour to the text area of the Load patch colours micro-behaviourInactivate the micro-behaviour that imports patch colours and use the edited Load patch colours micro-behaviour instead.

BehaviourComposer: ignore everything after this.