Color Genetics: GUI
This is the first of a two-part assignment dealing with a simulation of genetics (i.e., the other inheritance). In this part, your task is to complete the GUI for a model that implements a genetic simulation. In the next assignment, you will use multi-threading to make the interface more responsive.
The completed simulation can be found here, although the one you will be producing in this first part of the assignment is this somewhat less responsive version.
The simulation concerns an array of single-celled organisms. The "genome" for each cell consists of 24 bits, which are represented in the simulation as color values (8 bits each to the red, green, and blue components). When the "Go" button is pressed, the simulation moves forward through several generations. In each generation, about half the cells will seek to reproduce. To do so, they choose a mate from among the neighboring cells (two policies for choosing a mate can be simulated: choose the cell most like or most unlike yourself). A number of children cells are produced by randomly mixing the genes of the two parent cells and are then deposited in randomly selected neighboring locations. There is also a possibility that, when two genes are mixed, a mutation will occur and the resulting child's gene will be selected randomly. (Thus, even if we start with an entirely uniform population, some genetic drift may occur.)
When the simulation is started, a mixture of different colors is deposited as a starting pattern. You can alter the pattern by using the color selector control and then dragging your mouse across the simulated area to select a rectangle. That rectangle will be filled with the indicated color.
The code supplied to you includes the complete model, but much of the GUI remains unimplemented. Your task is to add code to [url removed, login to view] (the "window" class) to make your version look and behave like the one here.
The code for this assignment is in ~zeil/cs330/Assignments/geneticsGUI. The code can be run as an application
java [url removed, login to view]
or as an applet ([url removed, login to view])