Esempio n. 1
0
 def __repr__(self):
     return "\n\n" + repr(self.gene) + "\n" + funclist.makeReadable(self.gene)
Esempio n. 2
0
        # we may want to change this later, so that some functions are more or less likely to occur
        
    def mutateGene(self):
        # number of mutations! will be at least one.
        for i in range(0, int(round(math.ceil(self.pmut * self.length)))):
            # this can be improved by making it an iterable generator function
            self.mutateNode(self.pickRandomNode())
        return i + 1
            
if __name__ == "__main__":
    # remove this junk later
    
    gft = GeneFunctionTree()
    
    for j in xrange(0,1000):
        gft.initializeGene()
        for i in xrange(0,10):
            gft.mutateGene()
        
        #if j % 1000 == 0:
        print j, gft.length
        gft.interpret()
        
    print gft.gene
    
    print "is the same as:"
    print funclist.makeReadable(gft.gene)
    print "which produces:"
    
    print gft.interpret()