CodeReclaimers / neat-python

Python implementation of the NEAT neuroevolution algorithm
BSD 3-Clause "New" or "Revised" License
1.43k stars 496 forks source link

Issue with DefaultGenome.distance #158

Open iamdaviddunlap opened 5 years ago

iamdaviddunlap commented 5 years ago

When calling the distance(other, config) function from DefaultGenome, I am getting the following error:

Traceback (most recent call last): File "C:\Users\David Dunlap\AppData\Local\Programs\Python\Python37-32\lib\multiprocessing\pool.py", line 121, in worker result = (True, func(*args, *kwds)) File "C:\Users\David Dunlap\Desktop\saves\gym_play_train.py", line 77, in eval_genome action = agent.act(ob, reward, done, brain, genome, config) File "C:\Users\David Dunlap\Desktop\saves\gym_play_train.py", line 45, in act print(genome.distance(self.first_genome, config)) File "C:\Users\David Dunlap\AppData\Local\Programs\Python\Python37-32\lib\site-packages\neat_python-0.92-py3.7.egg\neat\genome.py", line 417, in distance node_distance += n1.distance(n2, config) File "C:\Users\David Dunlap\AppData\Local\Programs\Python\Python37-32\lib\site-packages\neat_python-0.92-py3.7.egg\neat\genes.py", line 95, in distance return d config.compatibility_weight_coefficient AttributeError: 'Config' object has no attribute 'compatibility_weight_coefficient

I believe the issue is caused by line 95 of genes.py which calls config.compatibility_weight_coefficient. However, the config never has this attribute, instead, I believe it should have config.genome_config.compatibility_weight_coefficient. Am I doing something wrong, or is there a problem with the source code?

iamdaviddunlap commented 5 years ago

Resolved: I am dumb, I was calling the function incorrectly. I was calling print(genome.distance(self.first_genome, config)) When instead it should be print(genome.distance(self.first_genome, config.genome_config))