OO Programming in Java
Class 7 Material
Kauffman Boolean Network
I have included this example to demonstrate rapid drawing in Java using a MemoryImageSource.
MemoryImageSources are fast but you lose a lot of the drawing facilities (i.e. drawRectangle) that you normally have available. 'Drawing' is done directly on pixels (ints) using an RGB color model. A typical pixel is (in hexadecimal) 0xff2356ba. The first byte from the left is always ff (for now but I believe it's supposed to be transparancy later .. I tried it but it just gave me funny looking pixel combinations) . The next bytes are the red value, green value and blue value respectively. Once the pixels are set the image is drawn. This technique is about 3-5 times faster than normal drawing.
Background:
A Kauffman Boolean Network is a network of BooleanElement node objects.
A BooleanElement's state is determined by two inputs and by it's boolean rule (AND, OR, etc). Each BooleanElement's rule is randomly determined at initialization. If a particular BooleanElement has inputs 0 and 1, and it's rule is OR, then it's output is a 1.
BooleanElements are connected together to form a network such that each BooleanElement is connected to exactly two others. The state of a BooleanElement's two neighbors provide its inputs and its rule determine its outputs. These networks are allowed to step through states. A network advances to the next state when each BooleanElement reads it neighbors and computes a new output based on its boolean rule.
The interesting characteristic of these networks is that they fall into stable loops very quickly, a loop being a sequence of states that keeps repeating, i.e. the state of each BooleanElement is identical to its state in a previous time step.
If a network has 10,000 nodes the number of possible states is approximately 10 with 3000 zeros after it, yet after perhaps 1000 steps a stable sequence of states is formed.
Why is this interesting?
These networks can be thought of as a system for simulating an artificial chemistry. It could indicate how life on earth got started. The 'network' might be a sea of molecules each reacting with its neighbors. Eventually stable chemical systems could have been formed to provide the basis for life.