示例#1
0
        public NeuralNet Crossover(NeuralNet net1, NeuralNet net2, int ver)
        {
            NeuralNet localNet = new NeuralNet(new List <List <List <float> > >(), 0);

            for (int i = 0; i < NeuralNet.layersCount; i++)
            {
                localNet.Layers.Add(NeuralNet.CrossLayers(net1.Layers[i], net2.Layers[i], rand.Next(NeuralNet.neuronCount), ver));
                rand = new System.Random(rand.Next());
                for (int n = 0; n < rand.Next(1, 4); n++)
                {
                    rand = new System.Random(rand.Next());
                    localNet.mutate(i, GetInstanceID() + n);
                }
            }
            return(localNet);
        }
示例#2
0
 void Start()
 {
     rotation = transform.eulerAngles;
     rigid    = GetComponent <Rigidbody2D>();
     thisPos  = this.transform.position;
     Inputs   = new List <float>(new float[NeuralNet.neuronCount]);
     text     = GameObject.Find("Text").GetComponent <Text>();
     r        = GetComponent <Rigidbody2D>();
     this.GetComponent <Animator>().speed = 2f;
     allDirections = new List <Vector2>();
     allDirections.Add(new Vector2(0, 1));
     allDirections.Add(new Vector2(1, 1));
     allDirections.Add(new Vector2(1, 0));
     allDirections.Add(new Vector2(1, -1));
     allDirections.Add(new Vector2(0, -1));
     if (Data.NeuralNets.Count < Data.PopulationCount)
     {
         net = new NeuralNet(GetInstanceID());
         Data.NeuralNets.Add(net);
     }
 }