Example #1
0
// 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);
    }
}
Example #2
0
// 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);
    }
}