Ejemplo n.º 1
0
    public bool DebugTimestamps = true; // If true, evolution steps taking longer than 5 seconds are logged to console

    public Population(int size, int numInputs, int[] hiddenLayers, int numOutputs)
    {
        // Initialize objects
        Subjects        = new List <Subject>();
        Species         = new List <Species>();
        Speciator       = new Speciator(SpeciesCompatiblityThreshhold);
        TopologyMutator = new TopologyMutator();
        WeightMutator   = new WeightMutator();
        MutateAlgorithm = new MutateAlgorithm(TopologyMutator, WeightMutator, BaseWeightMutationChancePerGenome, BaseTopologyMutationChancePerGenome);

        // Initilaize parameters
        CurrentMutationChanceScaleFactor = StartMutationChanceFactor;

        // Create initial population
        CreateInitialPopulation(size, numInputs, hiddenLayers, numOutputs, InitialGenomesAreFullyConnected);
    }
Ejemplo n.º 2
0
    public MutateAlgorithm(TopologyMutator topologyMutator, WeightMutator weightMutator, float baseWeightMutChance, float baseTopMutChance)
    {
        BaseWeightMutationChancePerGenome   = baseWeightMutChance;
        BaseTopologyMutationChancePerGenome = baseTopMutChance;

        if (BaseTopologyMutationChancePerGenome + BaseWeightMutationChancePerGenome > 1f)
        {
            throw new Exception("Sum of weight mutation chance and topology mutation chance is greater than 1! This is not allowed.");
        }
        Random          = new System.Random();
        TopologyMutator = topologyMutator;
        WeightMutator   = weightMutator;

        WeightMutatedGenomes   = new HashSet <Genome>();
        TopologyMutatedGenomes = new HashSet <Genome>();
        NewNodeMutations       = new List <NewNodeMutation>();
        NewConnectionMutations = new List <NewConnectionMutation>();
    }
Ejemplo n.º 3
0
    // Start is called before the first frame update
    void Start()
    {
        TopologyMutator        = new TopologyMutator();
        WeightMutator          = new WeightMutator();
        NewNodeMutations       = new List <NewNodeMutation>();
        NewConnectionMutations = new List <NewConnectionMutation>();

        ResetBoth_Button.onClick.AddListener(ResetBoth_OnClick);
        TopologyMutationToBoth_Button.onClick.AddListener(TopologyMutationToBoth_OnClick);

        P1_MutateTopology_Button.onClick.AddListener(P1_MutateTopology_OnClick);
        P1_MutateWeight_Button.onClick.AddListener(P1_MutateWeight_OnClick);

        P2_MutateWeight_Button.onClick.AddListener(P2_MutateWeight_OnClick);
        P2_MutateTopology_Button.onClick.AddListener(P2_MutateTopology_OnClick);

        CreateChild_Button.onClick.AddListener(CreateChild_OnClick);
    }