コード例 #1
0
ファイル: RandomMutation.cs プロジェクト: AmirAbrams/noid-1
        MutationMemory CreateMemory()
        {
            MutationMemory memory = new MutationMemory();

            memory.Mutate = Mutate;
            return(memory);
        }
コード例 #2
0
        protected override MutationMemory Remember(ParameterSet initialExample, ParameterSet mutatedExample)
        {
            string focusPath = mutatedExample.GetDifference(initialExample).FieldPath;

            MutationMemory memory = new MutationMemory();
            memory.Lifetime = memory.ResetLifetime = 10;
            memory.Mutate = delegate(ParameterSet initial)
            {
                ParameterSet mutated = initial.Clone();
                ParameterValue parameter = mutated.Get(focusPath);
                Mutate(parameter);
                return mutated;
            };
            memory.IsRelevant = (initial, mutated) => mutated.GetDifference(initial).FieldPath == focusPath;
            return memory;
        }
コード例 #3
0
ファイル: ManualMutation.cs プロジェクト: AmirAbrams/noid-1
 protected override IEnumerable <MutationMemory> InitializeMemory()
 {
     foreach (string parameterPath in ParameterPaths)
     {
         string         parameterPathCopy = parameterPath;
         MutationMemory memory            = new MutationMemory();
         memory.Lifetime = memory.ResetLifetime = 20;
         memory.Mutate   = delegate(ParameterSet initial)
         {
             ParameterSet   mutated   = initial.Clone();
             ParameterValue parameter = mutated.Get(parameterPathCopy);
             Mutate(parameter);
             return(mutated);
         };
         memory.IsRelevant = (initial, mutated) => mutated.GetDifference(initial).FieldPath == parameterPathCopy;
         yield return(memory);
     }
 }
コード例 #4
0
        public void Feedback(ParameterSet initial, ParameterSet mutated, bool improved)
        {
            foreach (MutationMemory memory in Live)
            {
                if (memory.IsRelevant(initial, mutated))
                {
                    memory.Feedback(improved);
                    return;
                }
            }

            if (improved)
            {
                MutationMemory added = Remember(initial, mutated);
                if (added != null)
                {
                    Live.Add(added);
                }
            }
        }