Exemplo n.º 1
0
        private static INeighbour DoCrossover(INeighbour mother, INeighbour father)
        {
            var motherWeights = mother.Network.GetFlattenedWeights();
            var fatherWeights = mother.Network.GetFlattenedWeights();

            int crossoverPosition = Random.Next(1, motherWeights.Length - 1);


            var offsprintWeights = new List <float>(motherWeights.Length);

            for (int i = 0; i < motherWeights.Length; i++)
            {
                offsprintWeights.Add(i < crossoverPosition ? motherWeights[i] : fatherWeights[i]);
            }

            var offspring = new CarAi(new int[] { 12, 12, 12, 4 }, Random, offsprintWeights);

            return(offspring);
        }
Exemplo n.º 2
0
 private void Awake()
 {
     manage = this;
 }