Okay, so I have an assignment to code (using Java,but I don’t think that matters) a simulation / model of inheritance as in the Biology sense, not OOP , i.e you know, father with brown eye / hair, mom with black eye / hair etc. thing.
I am facing two difficulties, firstly how do I start? I’ve never programmed a simulation before and don’t know a thing about it. I considered that since I am using Java, I might as well use applets, rather than an offline simulation, but anyway, is there some sort of tutorial or guide, or explanation anywhere on how to code simple graphical simulations?
Secondly, is there any existing simulation (with or without source code) of biological inheritance? It will give me an idea on what exactly I should make, and if the source is available, it may prove very helpful.
In short
Q-1 How exactly do you program graphical simulations?
and
Q-2 Are there any existing simulations of biological inheritance on the internet?
Here is my guess on how to solve your problem.
Have a list of organisms that represent all of the possible organisms at the current generation.
Each organism stores its genetic makeup. You do not need backwards references to the parent organisms(you do not care about previous generations).
Then when the user selects their chosen pair, clear the list and generate a new list with those two organisms, with each possible combination of genes.
Then draw the list on the screen, and allow the user to select two more.
EDIT
Also, here is a random idea of how to generete your gametes for an arbitrary size.
Binary numbers slowly cycle through all 0’s and 1’s. So, if you went from 0 to 7, you would go through every combination of 000 to 111. Thus you can think of a 0 as being the left allele, and a 1 as being the right allele(for example, the number 5, with the representation 101 would mean a gamete of AbC for the genotype aAbBcC) . Therefore you can generate every possible allele combination when you go from 0 to 2^(numOfAlleles-1) (inclusive). This would require bit shifting to detect which bits are set.
The rest would simply be a punnet square.