Пример #1
0
        public void RandomMutation(float MutationRate)
        {
            int index = EvoGame.RandomInt(hiddenNeurons.Count + outputNeurons.Count);

            if (index < hiddenNeurons.Count)
            {
                ((WorkingNeuron)hiddenNeurons[index]).RandomMutation(MutationRate);
            }
            else
            {
                ((WorkingNeuron)outputNeurons[index - hiddenNeurons.Count]).RandomMutation(MutationRate);
            }
        }
Пример #2
0
        public Creature(Creature mother)
        {
            id = currentId++;
            //this.mother = mother;
            generation = mother.generation + 1;
            if (generation > _maximumGeneration)
            {
                _maximumGeneration = generation;
            }
            this.pos       = mother.pos;
            this.viewAngle = EvoGame.RandomFloat() * Mathf.PI * 2;
            this.brain     = mother.brain.CloneFullMesh();

            SetupVariablesFromBrain();


            CalculateFeelerPos(MAXIMUMFEELERDISTANCE);
            for (int i = 0; i < 10; i++)
            {
                brain.RandomMutation(0.1f);
            }

            int r = mother.color.R;
            int g = mother.color.G;
            int b = mother.color.B;

            r += EvoGame.RandomInt(-5, 6);
            g += EvoGame.RandomInt(-5, 6);
            b += EvoGame.RandomInt(-5, 6);

            r = Mathf.ClampColorValue(r);
            g = Mathf.ClampColorValue(g);
            b = Mathf.ClampColorValue(b);

            color = new Color(r, g, b);
            GenerateColorInv();

            if (CreatureManager.SelectedCreature == null || CreatureManager.SelectedCreature.Energy < 100)
            {
                CreatureManager.SelectedCreature = this;
            }
        }
Пример #3
0
        public void RandomMutation(float MutationRate)
        {
            Connection c = connections[EvoGame.RandomInt(connections.Count)];

            c.weight += (float)EvoGame.RandomFloat() * 2 * MutationRate - MutationRate;
        }