private static float XDistToNextColumn(BirdGenome genome) { if (_facingCol == null) { return(0); } return((_facingCol.center.transform.position.x - genome.transform.position.x) / ColumnControl.instance.xColMaxDelta); }
/// <summary> /// The y difference between this object and the center of the facingCenter can /// be negative.To normalize this value, a maxDelta is added. /// </summary> private static float YDistToNextColumn(BirdGenome genome) { float deltaY, maxDelta; if (_facingCol == null) { return(0); } maxDelta = ColumnControl.instance.yColMaxDelta; deltaY = _facingCol.center.transform.position.y - genome.transform.position.y; return((deltaY + maxDelta) / (2 * maxDelta)); }
private void _InitPopulation() { _population = new Population(new Genome[_genomeCount], _mutationChance, _mutationVal); for (int i = 0; i < _genomeCount; i++) { BirdGenome newOrganizm = Instantiate(_genomePrefab, transform).GetComponent <BirdGenome>(); newOrganizm.transform.position = transform.position; newOrganizm.Id = i; _birdGenomes[i] = newOrganizm; _population.Genomes[i] = new Genome( inputsNeuronsC: BirdGenome.inputs.Count, hiddenNeuronsC: hiddenNeurons, outputsC: 1, weightRandomValue: RandomGenomeWeightsVals ); } }
void Awake() { myTarget = (BirdGenome)target; }
/// <summary> /// Creates an array of inputs (float values) between 0 and 1. /// It actualy works even if the input values aren't normalized, but it /// converges faster when the inputs are normalized. /// </summary> private static float[] GetNormalizedInputs(BirdGenome genome) { return(inputs.Select(f => f(genome)).ToArray()); }