The first question I asked was how cells differentiate. Everything in a cell is controlled by chemicals. The chemicals in and around a cell are generally proteins. The production of these proteins is controlled by genes in the cell's DNA. In addition, cells can release proteins to affect the cells around them. Proteins are responsible for the behavior of cell. I reasoned that different chemical concentrations around a cell during its creation and lifetime would control how that cell differentiated.
These proteins also turn the cell's genes on and off. The mixture of proteins determines what proteins will be created in the next instance. In effect the cell becomes a complex protein state machine. Each on/off combination of genes defines a state. These genes adjust the protein mixture, which then determine the next state.
A cell is born, at some point a protein combination turns on the genes that produce proteins causing the cell to divide. The new cells start out with protein combinations different from the parent cell and exhibit new behavior. Each of these cell follows its predefined chemical state machine; dividing when it should; binding to the correct cells around it to form the right shape; causing other cells around it to form similar tissues for organs; slowly forming an organism through cell differentiation.
Each critter has a set of genes implemented as an instruction tree. Each tree returns a single value. This value controls the production of a single protein (implemented as a double that goes up or down). The operators of the trees are add, subtract, multiply, divide, max, min, if, abs, accrue, decay, and negative. The terminals of the tree are the protein values. Each tree is a function of protein values that control production of a single protein. Some proteins determine how a critter moves. Others do nothing but affect state. Some proteins affect other critters. In addition, there are several sensing proteins that are not affected by genes. These let the critter know how much energy it has and gives it some constant values to play with.
Several critters are released into a space with food. Each time step each critter loses some energy. If a critter passes over food, the food disappears and the critter receives some energy. New food is added each time step (there is a limit on food density). In addition, there is a prisoner's dilemma going on. One of the proteins acts as a messenger. If the protein is positive, the critter is cooperating. If it is negative, the critter is defecting. The amount of energy a critter loses is adjusted by its signal and the signal of critters around it. So far, I haven't seen an obvious signs that this affects the simulation.
When a critter's energy reaches zero or leaves the screen, it dies and is removed. Two living critters are selected at random. Their genes are crossed and mutated using Koza's genetic programming techniques. The new critter is then released in the center of the screen. Over time the critters evolve to stay on the screen. As more time passes, they evolve to cover more of the screen. It is a very interesting, and in my opinion, beautiful, process to watch. Note that the oldest critter is a different color than the others.
I've also playing with evolving critters to go to specific areas on the screen. I can get them to go to first area, but I have not been successful in getting them to go to two waypoints.
One reason I think the critters evolve so well is that successful strategies quickly become useless as every critter begins to exploit it. Following the same path as another critter is not good since there will be no food there. The gene pool is forces to adapt. After the simulation runs awhile, evolution really slows down. I think this is because the critters don't die as often so there is less chance for variation. I would like to vary the food production to keep the death rate at a constant level to see what happens.