Evolve演化仿真引擎
Evolve 是一个用 Objective-C 编写的演化仿真引擎。
示例代码:
- (void)evaluateFitnessForPopulation { NSArray *organisms = self.evolutionManager.population.organisms; for (Organism *organism in organisms) { NSString *genomeString = organism.genome.sequence; NSInteger geneSequenceLength = genomeString.length; NSInteger correctCharacters = 0; for (NSInteger charIndex = 0; charIndex < geneSequenceLength; charIndex++) { if ([genomeString characterAtIndex:charIndex] == [kTargetString characterAtIndex:charIndex]) { correctCharacters++; } } organism.fitness = correctCharacters; } }
评论