#ifndef lint static char *rcsid = "$Header: /tmp_mnt/vida/disk5/users/terry/r/gassy/my_name/RCS/my_name.c,v 1.1 1992/08/09 22:31:39 terry Exp terry $"; #endif /* * This program tries to find strings of length 5 over the lower case * alphabet that spell 'terry'. Fitness is the number of letters in * correct positions. It demonstrates how to specify different possible * alleles at each locus of the genome. */ #include "types.h" #include "public.h" #define GENOME_SIZE 5 INT app_individual_size() { return GENOME_SIZE; } FITNESS app_evaluate_individual(who, context) INT who; CONTEXT *context; { register FITNESS fitness = (FITNESS) 0; register INDIVIDUAL_TYPE genome = context->population[who].genome; if (genome[0] == 't') fitness++; if (genome[1] == 'e') fitness++; if (genome[2] == 'r') fitness++; if (genome[3] == 'r') fitness++; if (genome[4] == 'y') fitness++; return fitness; } VOID app_allele_possibilities(alleles) LOCUS *alleles; { static STRING alphabet = "abcdefghijklmnopqrstuvwxyz"; register INT i; for (i = 0; i < GENOME_SIZE; i++){ alleles[i].possible_alleles = alphabet; } return; }