Create and use CHANNELS_PER_PIXEL constant
Move code to new generateStatePixelColour() method
Miscellaneous improvements to comments, quotes, layout