def genome_simple_shuffle(): config = get_config() c1 = genome.ConnectionGene(1, 3, 0.5, innov_num=5) c2 = genome.ConnectionGene(2, 3, 0.5, innov_num=6) c3 = genome.ConnectionGene(1, 4, 0.1, innov_num=7) c4 = genome.ConnectionGene(4, 3, 0.8, innov_num=8) c5 = genome.ConnectionGene(9, 3, 0.25, innov_num=10) c6 = genome.ConnectionGene(4, 9, 0.333, innov_num=11) c7 = genome.ConnectionGene(2, 12, 0.22, innov_num=13) c8 = genome.ConnectionGene(12, 4, 0.22, innov_num=14) c9 = genome.ConnectionGene(1, 15, 0.1, innov_num=16) c10 = genome.ConnectionGene(15, 3, 0.1, innov_num=17) n1 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], node_type='input', innov_num=1) n2 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], node_type='input', innov_num=2) n3 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], node_type='output', innov_num=3) n4 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], innov_num=4) n5 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], innov_num=9) n6 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], innov_num=12) n7 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], innov_num=15) connections = { c1.innov_num: c1, c2.innov_num: c2, c3.innov_num: c3, c4.innov_num: c4, c5.innov_num: c5, c6.innov_num: c6, c7.innov_num: c7, c8.innov_num: c8, c9.innov_num: c9, c10.innov_num: c10 } nodes = { n1.innov_num: n1, n2.innov_num: n2, n3.innov_num: n3, n4.innov_num: n4, n5.innov_num: n5, n6.innov_num: n6, n7.innov_num: n7 } g1 = genome.Genome(config=config) g1.node_genes = nodes g1.connection_genes = connections return g1
def create_initial_individual(self, _inputs, _outputs): _inputs += 1 if self.kBias_node else 0 first_genome = genome.Genome(config=self.config) innov_num = 1 for input_node in range(_inputs): first_genome.node_genes[innov_num] = genome.NodeGene( sigmoid_power=self.kSigmoid_power, node_type='input', innov_num=innov_num) innov_num += 1 for output_node in range(_outputs): first_genome.node_genes[innov_num] = genome.NodeGene( sigmoid_power=self.kSigmoid_power, node_type='output', innov_num=innov_num) innov_num += 1 for in_node in first_genome.node_genes.values(): if in_node.node_type == 'input': for out_node in first_genome.node_genes.values(): if out_node.node_type == 'output': first_genome.connection_genes[ innov_num] = genome.ConnectionGene( in_node.innov_num, out_node.innov_num, random.gauss(0, 1), innov_num=innov_num) innov_num += 1 return Individual(first_genome, self.kBias_node)
def genome_basic(): config = get_config() c1 = genome.ConnectionGene(1, 2, 0.1, innov_num=3) n1 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], node_type='input', innov_num=1) n2 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], node_type='output', innov_num=2) connections = { c1.innov_num: c1, } nodes = { n1.innov_num: n1, n2.innov_num: n2, } g1 = genome.Genome(config=config) g1.node_genes = nodes g1.connection_genes = connections return g1
def genome_isolated_output_node(): config = get_config() c1 = genome.ConnectionGene(1, 3, 0.1, innov_num=5) c2 = genome.ConnectionGene(2, 3, 0.25, innov_num=6) c3 = genome.ConnectionGene(1, 4, 0.1, innov_num=7) c4 = genome.ConnectionGene(2, 4, -0.6, innov_num=8) n1 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], node_type='input', innov_num=1) n2 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], node_type='input', innov_num=2) n3 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], node_type='output', innov_num=3) n4 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], node_type='output', innov_num=4) # Isolate output node 4 c3.enabled = False c4.enabled = False connections = { c1.innov_num: c1, c2.innov_num: c2, c3.innov_num: c3, c4.innov_num: c4 } nodes = { n1.innov_num: n1, n2.innov_num: n2, n3.innov_num: n3, n4.innov_num: n4, } g1 = genome.Genome(config=config) g1.node_genes = nodes g1.connection_genes = connections return g1
def genome_six_nodes(): config = get_config() c1 = genome.ConnectionGene(1, 3, 0.6, innov_num=5) c2 = genome.ConnectionGene(2, 3, 0.75, innov_num=6) c3 = genome.ConnectionGene(1, 4, 0.6, innov_num=7) c4 = genome.ConnectionGene(4, 3, -0.1, innov_num=8) c5 = genome.ConnectionGene(1, 9, 0.1, innov_num=10) c6 = genome.ConnectionGene(9, 3, 0.1, innov_num=11) c7 = genome.ConnectionGene(1, 12, 0.3, innov_num=13) c8 = genome.ConnectionGene(12, 4, 0.1, innov_num=14) n1 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], node_type='input', innov_num=1) n2 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], node_type='input', innov_num=2) n3 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], node_type='output', innov_num=3) n4 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], innov_num=4) n5 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], innov_num=9) n6 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], innov_num=12) connections = { c1.innov_num: c1, c2.innov_num: c2, c3.innov_num: c3, c4.innov_num: c4, c5.innov_num: c5, c6.innov_num: c6, c7.innov_num: c7, c8.innov_num: c8 } nodes = { n1.innov_num: n1, n2.innov_num: n2, n3.innov_num: n3, n4.innov_num: n4, n5.innov_num: n5, n6.innov_num: n6 } g1 = genome.Genome(config=config) g1.node_genes = nodes g1.connection_genes = connections return g1
def genome_four_nodes_recursive(): config = get_config() c1 = genome.ConnectionGene(1, 3, 0.1, innov_num=5) c2 = genome.ConnectionGene(2, 3, 0.25, innov_num=6) c3 = genome.ConnectionGene(1, 4, 0.1, innov_num=7) c4 = genome.ConnectionGene(4, 3, -0.6, innov_num=8) c5 = genome.ConnectionGene(4, 4, 0.25, innov_num=9) # Recursive connection n1 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], node_type='input', innov_num=1) n2 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], node_type='input', innov_num=2) n3 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], node_type='output', innov_num=3) n4 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], innov_num=4) connections = { c1.innov_num: c1, c2.innov_num: c2, c3.innov_num: c3, c4.innov_num: c4, c5.innov_num: c5 } nodes = { n1.innov_num: n1, n2.innov_num: n2, n3.innov_num: n3, n4.innov_num: n4, } g1 = genome.Genome(config=config) g1.node_genes = nodes g1.connection_genes = connections return g1
def genome_recursive_two_outputs(): config = get_config() c1 = genome.ConnectionGene(1, 3, 1.0, innov_num=5) c2 = genome.ConnectionGene(2, 3, 1.0, innov_num=6) c3 = genome.ConnectionGene(1, 4, -1.0, innov_num=7) c4 = genome.ConnectionGene(2, 4, -1.0, innov_num=8) c5 = genome.ConnectionGene(1, 9, 0.0, innov_num=10) c6 = genome.ConnectionGene(9, 4, 0.5, innov_num=11) c7 = genome.ConnectionGene(9, 9, 1.0, innov_num=12) n1 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], node_type='input', innov_num=1) n2 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], node_type='input', innov_num=2) n3 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], node_type='output', innov_num=3) n4 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], node_type='output', innov_num=4) n5 = genome.NodeGene(sigmoid_power=config['kSigmoid_power'], innov_num=9) connections = { c1.innov_num: c1, c2.innov_num: c2, c3.innov_num: c3, c4.innov_num: c4, c5.innov_num: c5, c6.innov_num: c6, c7.innov_num: c7 } nodes = { n1.innov_num: n1, n2.innov_num: n2, n3.innov_num: n3, n4.innov_num: n4, n5.innov_num: n5 } g1 = genome.Genome(config=config) g1.node_genes = nodes g1.connection_genes = connections return g1