예제 #1
0
파일: parser.cpp 프로젝트: maleadt/genetic
// Output the DNA
void Parser::print(std::ostream& iStream, const DNA& iDNA) {
    for (unsigned int i = 0; i < iDNA.genes(); i++) {
        // Extract the gene
        unsigned char* tGene;
        unsigned int tSize;
        iDNA.extract_gene(i, tGene, tSize);

        // Print the block
        std::cout << "* Human-readable version of block " << i << std::endl;
        print_block(iStream, tGene, tSize);

        // Free the block
        free(tGene);
    }
}
예제 #2
0
파일: parser.cpp 프로젝트: maleadt/genetic
// Evaluate DNA
void Parser::evaluate(const DNA& iDNA) {
    // Reset the quotum
    mInstructionCounter = 0;

    // Evaluate all blocks
    for (unsigned int i = 0; i < iDNA.genes(); i++) {
        // Extract the blocks
        unsigned char* tGene;
        unsigned int tSize;
        iDNA.extract_gene(i, tGene, tSize);

        // Evaluate the block
        evaluate_block(tGene, tSize);

        // Free the block
        free(tGene);
    }
}