示例#1
0
 public void Visit(FuncExpression <T> expression)
 {
     if (_random.NextDouble() < _mutationRate.GetValue())
     {
         MutateFuncExpression(expression);
     }
 }
示例#2
0
            public T GetValue()
            {
                if (_inputSource != null)
                {
                    return(_inputSource.GetValue());
                }

                return(default(T));
            }
示例#3
0
            public T GetValue <T>() where T : struct
            {
                //Make sure output node matches requested type
                if (_outputNode != null && typeof(IValueSource <T>).IsAssignableFrom(_outputNode.GetType()))
                {
                    IValueSource <T> outputNode = _outputNode as IValueSource <T>;
                    return(outputNode.GetValue());
                }

                return(default(T));
            }
示例#4
0
 public override void Update(float time, float deltaTime)
 {
     if (_inputSource != null)
     {
         _value = _inputSource.GetValue();
     }
     else
     {
         _value = default(T);
     }
 }
示例#5
0
        public override ReevaluationResult Reevaluate()
        {
            if (valueSource != null)
            {
                var value = valueSource.GetValue();
                if (value.HasValue)
                {
                    setValue(value.Value);

                    return(base.Reevaluate());
                }
            }

            return(ReevaluationResult.NoChange);
        }
示例#6
0
        public void Mutate(T genome)
        {
            var propertiesToMutate = _genomeDescription.Properties
                                     .Where(p => NextDouble() < _mutationProbability.GetValue())
                                     .ToList();

            if (!propertiesToMutate.Any())
            {
                propertiesToMutate.Add(_genomeDescription.Properties.OrderBy(p => NextDouble()).First());
            }

            foreach (var property in propertiesToMutate)
            {
                property.Mutate(genome);
            }
        }
示例#7
0
            public T GetValue()
            {
                switch (_sourceType)
                {
                case eSourceType.Node:
                    if (_sourceObject != null)
                    {
                        return(_sourceObject.GetValue());
                    }
                    break;

                default:
                case eSourceType.Static:
                    return(GetStaticValue());
                }

                return(default(T));
            }
示例#8
0
            public T GetValue()
            {
                if (_sourceObject != null)
                {
                    IValueSource <T> sourceObject = _sourceObject as IValueSource <T>;

                    if (sourceObject != null)
                    {
                        return(sourceObject.GetValue());
                    }
                    else
                    {
                        throw new Exception("Object not type of IValueSource<" + typeof(T).Name + ">");
                    }
                }
                else
                {
                    return(_value);
                }
            }
示例#9
0
        public ReevaluationResult Reevaluate()
        {
            // TODO again, I think the engine should do that
            if (valueSource != null)
            {
                UnderlyingValueHasBeenChanged();
                var value = valueSource.GetValue();
                if (value.HasValue)
                {
                    // TODO Don't set and return NoChange when value has not changed
                    setValue(value.Value);
                    return(ReevaluationResult.Changed);
                }

                exceptionHandler(value.Exception);
                return(ReevaluationResult.Error);
            }

            return(ReevaluationResult.NoChange);
        }
示例#10
0
 public object GetValue(object target)
 {
     //return _field.GetValue(target);
     return(_source.GetValue(target));
 }