How about matching up the sections where the DNA matches ...
h r j d n v r g k h t r e s b j y o g d s w e h g k h p g r e s g p p o r d w t x n t o p l
h r j d n o I y t r v j b g h f d w e h p o d v d x b j r d w t x y y r l
... and using this as a guide to place in a random number of crossover points within the portions where the DNA matches, for each strand. This prevents code from getting accidentally mushed in with an entirely seperate piece of code
There is a problem with this in that for populations and genomes as small as what we are using, conspecs are likely to differ by perhaps only one or two base pairs, when they differ at all. Most of the genome of the individuals within a species will be identical and crossing over these portions will have no effect. For this reason and for those mentioned about the problems with defining/assuming specific universal genome structures, I prefer cross over without regard to genome structure in all cases (I.e. essentially random in both the number of cross over points and the locations - more on this below).
As previously mentioned, this has the effect of self-defining species in that the crossing over of similar genomes will have a higher probability of resulting in a viable organism then will the cross over of radically disimilar genomes. That is, it is unlikly that two organismsms of wide genetic distance will be able to produce viable offspring. Selection will determine how far is too far and we will have a species boundary. Sterile hybrids between recently branched but distinct species are an intermediate possibility, but selection will strongly favor mating with bots that have similar genomes and wouldn't it be cool if species recognition adaptations evolve one day as a result. A cross over point in the middle of a gene between two individuals of the same species won't matter much since it is likely that the other half of the gene is the same or sufficiently similar that the resulting gene will still function in the offspring. In cases where there are off by one type errors due to insertion mutations or other genetic differences between the parents, the resulting offspring may have a modest crossover mutation, which may or may not be deleterious. This could lead to the evolution of non-coding interons, the purpose of which would be to increase the possibility of retaining the original gene function in the offspring in cases where the crossover does not exactly line up due to differences in parential genomes. Random crossover also has the fucntion of creating a poor man's version of haplioid alleles.
But this all begs the question as to whether sexual reproduction should be entirely part of the engine, entirely coded for within the genome of sexually reproducing species or perhaps something inbetween. IMHO, in an ideal world, everything would be evolved and in the genome. The whole notion of sex and all the mechanisms there of would evolve naturally with the engine providing only the most basic world physics and chemistry necessary to enable it - say the ability of one organism to make it's DNA available to another, via a tie or perhaps as a new shot of type "gamate" which can contain all or part of an organism's DNA. But the entire notion of sex, sexes, crossover, alleles, diploidity, etc would evolve out of that basic ability naturally if and only if selection favored it. Crossing over would be under organism control, selection could operate on the number and location of crossover points, whether they were random, whether some genetic structure was assumed in crossover, sex ratios, etc.
Unfortunatly, given the limits of the system in terms of environmental diversity/complexity and of the CPU power available today, I expect we would be waiting a long time for all this to evolve since it is unclear to me at least what selection forces are necessary to favor sex in the first place. (I'm not the only one BTW. From what I can tell, what advantage there may be in sexual reproduction is a hot area of research. At first blush, it would seem that selection should favor asexual reproduction exclusivly since in sexual reproduction, only half of an organism's genes are passed on to an offspring. All else being equal, genes which favored asexual reproduction over sexual reproduction would become more numerous so there must be some important advantage conveyed by sexual reproduction. Some of the therories I have read about are nonobvious and involve such things as parasite resistance but I think the jury is still out for sure.)
So, I assume for expediecy sake, we want sexual reproduction including crossover to be handled pretty much entirely by the engine in that all an organism need evolve is invocation of .sexrepro or equivalent and the responsibility of doing the crossover and creating the offspring with the resulting DNA will be handled by the engine instead of by the organism. While it is tempting to say that the genome should be responsible for deciding what parts of it's DNA to combine with another's, this might add considerably to the difficulty of letting a successful cross over strategy evolve naturally. I'm all for allowing the organism to provide some sort of optional hints to the engine which serve to guide or control cerain aspects of crossover and letting selection operate on these, perhaps average crossover length for example, but I for one cannot come up with good ways for how selection would effectively operate on this.
This split between what the engine does and what the organims must evolve is consistant by the way with where we draw the line on other engine/genome responsibility splits. For example, the engine today handles all the various tasks of creating a new organism with the DNA of the parent during asexual reproduction including DNA copying and so on. An asexual organism need not evolve it's own DNA copying machinery in order to reproduce. I think it would be inconstistant of us to say that sexual reproduction must evolve in it's entirty but that asexual reproduction need not.
So, what remains is to decide on what specific mechanisms are available for bots to decide how and when to have sex. I suggest two methods:
Mammal sex I.e. tie method. Both parents have to be in the same place at the same time. They form a tie. They both have to be willing to have sex on the same cycle. If both call .tiesexrepro or equivalent on the same tie on the same cycle, the engine performs crossover and an offspring is formed endowed with the sum of the nrgs passed by its parents. A birth tie is formed to (and genetic memory loaded from) the one which passed the larger nrg value.
This approach could allow male/femaleness to evolve as bots of the same species can evolve different strategies for how much nrg to invest in fertilization and how often to attempt to have sex (initially, the only difference between males and females would be in the value of a single base pair governing how much nrg to invest in sexually produced offspring). Females for example, might evolve the strategy of investing a lot of nrg in each offspring but being choosy in the bots they mate with (since they invest so much in each offspring) say only mating with bots with nrg levels above a certain level as a test of fitness. Males on the other hand may take the differnet approach of investing very little nrg in each offspring, but attempting to mate often and with anything that will allow it. Selection can favor both strategies.
The delayed fertilization method. Both parents do not have to be in the same place at the same time. One parent lays an egg (which would be represented simply be a normal asexually produced offspring but with a couple of flags set that the engine would use and perhaps an "I'm an egg" refvar that others could use for recognition. That is, unlike say using a shot for the egg, the egg would be visiable, could be eaten by preditors, is subject to costs, can die if not fertilized, repsects corpse mode, etc) using .sexrepro or equivalent endowing it with it's DNA and some amount of energy. The offspring's DNA DOES NOT EXECUTE (only environmental costs apply - so it can die if not fertilized within some time frame) until it is fertilized by another bot at which time the engine crosses over the DNA of the parents and forms the new offspring with the new DNA and the offspring begins to execute. Fertilization happens via a tie as above. In fact, dumb bots need not know the difference between an egg and a mate - the egg can be thought of as calling .sexrepro every cycle (come fertilize me!) - the only difference is that when sex occurs, the egg becomes the offspring, no third bot is created. Or perhaps we really do kill the egg and create the offspring anew, complete with birth tie....
Note that fertilization could also occur via a new "gamate" shot type if we wanted. I would suggest this as a V2 feature since 1) it's not necessary initally 2) it's hard to hit really small bots with shots and eggs are likely to be small and 3) I don't know how birth ties and genetic memory should work in such cases.
Sorry to be long winded, but this subject is super interesting. Nums, I think this topic of sexual v. asexual reproduction in Alife simulators would be a good one for an acedemic paper...