Random colors are selected for each box. The colors from a boxes top, bottom, left, and right are averaged and set as the color for the new box. With some fiddling around with percentages and how the edges are handled, new patterns are made.
All patterns start out random. Button resets. Other than the button and the black right-half, everything is done in Actionscript 3. For more fun with automata and patterns, see Conway's Game of Life.