Skip to content

Wrong implementation of 75% rule in neat/genes.py #292

@SomeThink1729

Description

@SomeThink1729

I took a look at the code to understand it and got a bit confused at this section, so I read the paragraph in the paper.

The paper states

There was a 75% chance that an inherited gene was disabled if it was disabled in either parent.

This doesn't mean there's a 25% chance of it being enabled if both parents are disabled. However this is what the current code does. It has to be disabled if both parents are disabled already.

if not self.enabled or not gene2.enabled:
                # Override whatever was randomly inherited: 75% disabled, 25% enabled.
                new_gene.enabled = random() >= 0.75

It could look like this:

if self.enabled ^ gene2.enabled:
                new_gene.enabled = random() >= 0.75

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions