Save patch colours

BehaviourComposer: ignore everything before this.

Begin micro-behaviour:

Begin description:

Defines a reporter and command for saving and restoring patch colours.

End description

Define patch colour save and restore

Begin NetLogo code:

to-report patch-colors
report [(list pxcor pycor pcolor)] of patches
end

to load-patch-colors [saved-patch-colors]
foreach saved-patch-colors
        [ask (patch item 0 ? item 1 ?) [set pcolor item 2 ?]]
end

End NetLogo code

How this works

This defines patch-colors reporter which returns a list of patch coordinates and colors. 
It also defines load-patch-colors command which updates patch colors using a list produced by patch-colors .

This is particularly useful for running models in NetLogo Web which doesn't support NetLogo's import-pcolors and import-pcolors-rgb.
The recommended usage is to import the colors, then run patch-colors in NetLogo's command center.
Copy  the output of patch-colors to the text area of the Load patch colours micro-behaviour.
Inactivate the micro-behaviour that imports patch colors and use the editted Load patch colours micro-behaviour instead.

History

Implemented by Ken Kahn on 20 March 2016.

BehaviourComposer: ignore everything after this.

Comments