AlexTheM8 / AiAi-AI

3 stars 0 forks source link

Investigate issue with reproduction after stagnation #8

Closed AlexTheM8 closed 2 years ago

AlexTheM8 commented 2 years ago

Occasionally, the NEAT reproduction will fail after removing stagnated species. The crash happens at the following code in genome.py line 110, get_new_node_key:

    def get_new_node_key(self, node_dict):
        if self.node_indexer is None:
            self.node_indexer = count(max(list(iterkeys(node_dict))) + 1)

        new_id = next(self.node_indexer)

        assert new_id not in node_dict

        return new_id

One fix would be to loop as follows:

        if self.node_indexer is None:
            self.node_indexer = count(max(list(iterkeys(node_dict))) + 1)

        new_id = next(self.node_indexer)
        while new_id in node_dict:
            new_id = next(self.node_indexer)

        assert new_id not in node_dict

        return new_id

But this is editing the library and will not remain as a global fix. Investigate why this happens before asserting the library needs to be fixed.

AlexTheM8 commented 2 years ago

Since implementing the "fix" and restarting evolution, this has not been a noticeable issue. This could have been a config issue. Next evolution will involve removing this "fix" and seeing what happens.