I came up with the crossover operator as simple way to push as much control over the process into the DNA as possible. Selection can operate on the frequecy and position of crossover points by operating on the cross base pair. If you have a suggestion for how to do the same with your alignment scheme, I'm all ears, but I think it's important that as much of the alignment and corssover machinery as possible be "inside" the system and subject to selection.
This is obviously a point where we differ in philosophy. For me, the specifics of crossing over aren't "interesting" in a Darwinian sense. They've changed very little over billions of years, demonstrating that nature's way is sufficient and probably optimal for the way DNA works. And doing this matching wrong (called Unbalanced recombination), almost always results in the offspring's death. Nothing good comes from failure in this regard.
It's like shuffling a deck of cards. It's the overall result after several iterations that really matters. In an individual shuffle it's immaterial wether a card from pile A goes before or after a card from pile B, or even wether 20 cards from pile A all get deposited together or shuffled with some from B. Plus, lots of crossover commands clutter up the DNA, and force old bots to be retrofitted with them before they can have sex.
As for matching up DNA strands, I'm sure there's a way to produce a pretty good match using a hill climbing algorithm. It doesn't matter, say, if the matching is less than globally optimal. The fewer areas that are matched, the fewer places get cross over events, and the less likely the resultant DNA will represent a cohesive DNA program.
Here's my first pass at an implementation for matching:
1. Determine the longest sequence of base pairs that can be matched from strand A to strand B (if there's more than one match, pick one that causes the lengths to match up as much as possible for either strand).
2. "zip" the two strands together along this match.
3. Repeat 1 and 2 in such a way that a match must occur so that the DNA strands don't loop back on themselves. (That is, a match on strand A that is downstream of a previous match must also be downstream of that same match on strand . Repeat until either all the base pairs are matched in one of the strands, or the remaining strands can't be matched.
Step 1 can be implemented naively at O(n^2) at the least, though maybe there's a library function or existing algorithm that could be used that would cut that down. It all seems a little complex but very do able to me.
I'm not really fond of using the .sexrepro value to make this determination but I can't really think of anything better at the moment.
I think it's very simple: both parents get to be moms
if they want. After mating, both bots have the
option of producing a kid. The potential kid's DNA is stored in a buffer. The simplest method here would be to take the two recombinant DNA strands from the previous discussion and give one to each parent. The parent can either ignore making a kid (and thus be "male"), or make the kid (and thus be "female"). I think this is the prisoner's dilemma proper. In your original version, it isn't quite a prisoner's dilemma because the bots don't have the choice of cooperating (both producing kids).
I kind of lean towards using shots for fertilization and time-shifted sex as we already have a mechanism there for storing DNA in the shot. It's the only place currently where we have a "buffer" to put DNA outside a bot. Perhaps an egg laying female bot could reproduce asexually in a special "egg" mode where little happens until a sperm shot hits it...
The transmission of DNA is immaterial to me. It could be shots, ties, or magic leprechauns. At some point you have two DNA strands of either parent, and your goal is to mix them. That's the part that matters to me.
That said, we need to decide what sort of sexual model we're after. Sex for mammals is very familiar to us. Two animals get in to proximity, do the horizontal mamba, and then one of them makes a baby after a while. Sex for fish involves less proximity but the idea is essentially the same. Sex for worms is a little different:
both worms get potentially fertilized. They both can produce eggs. Sex for single celled critters is even more fun: the species goes through alternating generations of diploid and haploid. In the diploid phase, it's like two separate animals join to become one. The two strands of DNA sort of share control of the organism. Like in Dragonball Z where the main characters would fuse to become a new, stronger character with character traits of both fuse-ees.
That last form of sex is probably way beyond what present Darwinbots is capable of (though I'm working towards it for DB3), but the first, second, and third each seem equally valid to me. To you as well I hope.
I don't think a bot should be able to hang on to a mate's DNA in a buffer indefinantly. Sperm only lives so long. I think sexual reproduction should necessitate coordination in both time and space between parents, be that mammal sex as I've coded (where both need to be in the same place and the same time) or reptile/fish sex per egg offspring and sperm shots (where the male has to fertilize the egg and this act kicks off gestitation).
Not indefinately, no, but certainly over the life time of the bot. Ant queens usually mate once when they're in their "new queen" phase (have wings), and the entire colony grows from that initial seed. In a perfect world a bot would keep an entire store of possible genomes for its children, and choose one at random when it produces a kid. But I'll settle for storing a single copy until it's needed 100, 1000, or 10000 cycles after the pairing.