public void Visit(FuncExpression <T> expression) { if (_random.NextDouble() < _mutationRate.GetValue()) { MutateFuncExpression(expression); } }
public T GetValue() { if (_inputSource != null) { return(_inputSource.GetValue()); } return(default(T)); }
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)); }
public override void Update(float time, float deltaTime) { if (_inputSource != null) { _value = _inputSource.GetValue(); } else { _value = default(T); } }
public override ReevaluationResult Reevaluate() { if (valueSource != null) { var value = valueSource.GetValue(); if (value.HasValue) { setValue(value.Value); return(base.Reevaluate()); } } return(ReevaluationResult.NoChange); }
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); } }
public T GetValue() { switch (_sourceType) { case eSourceType.Node: if (_sourceObject != null) { return(_sourceObject.GetValue()); } break; default: case eSourceType.Static: return(GetStaticValue()); } return(default(T)); }
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); } }
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); }
public object GetValue(object target) { //return _field.GetValue(target); return(_source.GetValue(target)); }