Initcel()
Home ] Up ] [ Initcel() ] SelectParents ] CalcAllFitness ] GraphCellFitness ] PrintCell ] Declarations ]

 


The first thing that gets done is the construction of the cell where all this chromosome mating is going to happen. These two statements identify the arrays from where all the chomosomes get grabbed from and to where the modified ones--the ones that are either crossed over, mutated, or both--get placed

ReDim original_cell(CELL_W, CELL_H)
ReDim new_cell(CELL_W, CELL_H)


Eventually, one by one, the chromosomes will be grabbed from original_cell(-,-), then modified, and then placed in new_cell(-,-).  When new_cell(-,-) is full, that constitutes one generation.  But I'm getting ahead of myself.  In this Initcell routine, all that happens is we load up the array with random bit patterns of proper length.

wpe1.jpg (19966 bytes)

The genome array is also loaded. What's the genome?  That's constructed in the declarations part of the program by a constant.  For example:

     GENE_MAP As String = " 07 09"


In this case, gene 1 is 9 bits long, gene 2 is 7 bits long.  Each gene is defined in a schema of three. A spacing character followed by a two digit number. So the the maximum number of bits in a gene is 99. Believe me, that's enough for whatever you want to do. Keep in mind that gene one is always the first schema from the right. In the example below, gene 1 is 10, gene 2 is 7, gene 3 is 16:

     GENE_MAP As String = "+16+07+10"

Notice there is a spacing character between them.  It can be white space, or a plus sign.  This helps you keep straight the genome (i.e. the collection of all the genes in your chromosomes.) Make sure the spacing character is in front of all of your genes, including the last one, which would be 16 in the example just given.

In GENE_MAP above, we can see that gene three is 16 bits longs, gene two is 7 bits long, and gene one is 10 bits long.  Note that in gene 2, the biggest positive integer you could represent is 127, which is equal to 1111111 in binary.  Of course you could interpret it differently if you wanted -63 to +64 or something fancy like that by fiddling with the first bit as a sign indicator, but i like to keep everything nice and positive. Naturally, the number of bits in each gene is going to determine just how large an integer (or whatever) you can represent.