diff --git a/src/nodes.py b/src/nodes.py index aef1d12..70b2ddf 100644 --- a/src/nodes.py +++ b/src/nodes.py @@ -43,6 +43,8 @@ def add_node_mutation(self, connection:'ConnectionGene', node_id: int, global_in node1.add_node_connection(new_node.id) new_node.add_node_connection(node1.id) new_node.add_node_connection(node2.id) + new_node.add_connection_connection(connection2) + node1.add_connection_connection(connection1) def add_connection_mutation(self, node1: 'Node', node2: 'Node', global_innovation_number: int): @@ -67,7 +69,7 @@ def add_connection_mutation(self, node1: 'Node', node2: 'Node', global_innovatio self.add_connection(connection) node2.add_node_connection(node1.id) node1.add_node_connection(node2.id) - node1.add_connection(connection) + node1.add_connection_connection(connection) return True else: return False @@ -126,7 +128,7 @@ def update_value(self, value: float): def add_node_connection(self, node:'Node'): self.connected_nodes.append(node) - def add_connection(self, connection: 'ConnectionGene'): + def add_connection_connection(self, connection: 'ConnectionGene'): self.connections_to_output.append(connection) def __repr__(self): diff --git a/src/traverse.py b/src/traverse.py index 719d00e..6c52b1c 100644 --- a/src/traverse.py +++ b/src/traverse.py @@ -13,7 +13,7 @@ def traverse(self) -> None: all its incoming connections traversed before it. """ order_of_traversal = self.kahns_algorithm() - print(order_of_traversal) + # print(order_of_traversal) if not order_of_traversal: return None for node in order_of_traversal: @@ -95,7 +95,6 @@ def update_out_node_value(self, connection: 'nodes.ConnectionGene') -> None: weighted_input = self.calculate_weighted_input(connection) connection.out_node.value += weighted_input connection.out_node.value = self.activation_function(connection.out_node.value) - print(connection.out_node.value)