The main problem with implementing sexual reproduction is that since science doesn't even know why actual organisms have sex (there are some theories), so we aren't sure what we really need to implement, if we can take any shortcuts, etc.
There are several, possibly inter-related features of organisms that have sex.
- Diploidity - Although diploidness is the most common, many fungi even have up to dozens of each chromosome.
- Dominant, Co Dominant and Recessive expression - Most real life genes are either dominant, recessive, or more commonly co dominant. Is this required for sexual reproduction to be effective?
- Crossing Over - A shuffling of the parents' DNA before gifting to the child. Does crossing over need to happen between the parents' DNA itself, or can crossing over work between haploid strains of both parents?
- Chromosomes - Physically separated sections of DNA. Perhaps to separate certain genes from being able to cross over with each other? Perhaps totally pointless? If so why do organisms maintain it?
Because relatively little is known for sure about the role each has in sex and evolution, the safest (if most intensive) course of action is to model all of them. "How" becomes a hotly debatable question.
For simplicity Botsareus created a simple cross over algorithm to implement sex repro for version 2 of DarwinBots:
Here is a version of Animal_Minimalis that supports Sexual Reproduction:
'Animal_Minimalis 'By: Botsareus based on by Numsgil 'Good for mutation sims and for 'newbies to see how a basic bot works. 'Contains everything necessary for it 'to survive and reproduce. 'Sexrepro version
'Gene 1 Food Finder cond *.eye5 0 > *.refeye *.myeye != start *.refveldx .dx store *.refvelup 30 add .up store stop
'Gene 2 Mate Finder cond *.eye5 0 > *.refeye *.myeye = *.nrg 20000 > start *.refveldx .dx store *.refvelup 30 add .up store stop
'Gene 3 Eat Food cond *.eye5 50 > *.refeye *.myeye != start -1 .shoot store *.refvelup .up store stop
'Gene 4 Shoot Sperm cond *.eye5 50 > *.refeye *.myeye = *.nrg 20000 > start -8 .shoot store *.refvelup .up store stop
'Gene 5 Avoiding Family cond *.eye5 0 = *.refeye *.myeye = or *.nrg 20000 < and 'don't spin if time for sex repro start 314 rnd .aimdx store stop
'Gene 6 Look for Family cond *.refeye *.myeye != *.nrg 20000 > start 314 rnd .aimdx store 100 rnd .up store stop
'Gene 7 Reproduce cond *.nrg 20000 > start 10 .sexrepro store 'changed to sex repro stop