/* * This program tries to find binary character strings of length 64 * that consist of all ones. The fitness is the number of ones in the string. */ #include "types.h" #define GENOME_LENGTH 64 INT app_individual_size() { return GENOME_LENGTH; } FITNESS app_evaluate_individual(who, context) INT who; CONTEXT *context; { INT i; FITNESS fitness = (FITNESS) 0; INDIVIDUAL_TYPE genome = context->population[who].genome; for (i = 0; i < GENOME_LENGTH; i++) if (genome[i] == '1') fitness ++; return fitness; }