Ejemplo n.º 1
0
        private void FirstGeneration_Tick(object sender, EventArgs e)
        {
            label10.Text = "Generation num: " + Convert.ToString(generationNum);
            if (firstGenerationIteration == mobScore.Length)
            {
                Crossbreeding(BestMob(mobScore), BestMob(mobScore), BestMob(mobScore), BestMob(mobScore));
                Mutation();
                firstGenerationIteration++;
                FirstGeneration.Stop();
                OneGeneration.Start();
                return;
            }

            FillW(W01);
            FillW(W12);
            FillW(W23);

            //WeightsReader(W01, W12, W23, firstGenerationIteration);

            WeightsWriter(W01, W12, W23, firstGenerationIteration);

            mobUpIteration = 0;
            OneMobLifeCycle.Start();
            FirstGeneration.Stop();
        }
Ejemplo n.º 2
0
        private void OneGeneration_Tick(object sender, EventArgs e)
        {
            if (generationNum == 1)
            {
                label10.Text = "Generation Num: " + Convert.ToString(++generationNum);
                for (int i = 0; i < mobScore.Length; i++)
                {
                    mobScore[i] = 0;
                }
            }
            if (oneGenerationIteration == mobScore.Length)
            {
                Crossbreeding(BestMob(mobScore), BestMob(mobScore), BestMob(mobScore), BestMob(mobScore));
                Mutation();
                oneGenerationIteration++;
                OneGeneration.Stop();
                GlobalCycle.Start();
                return;
            }

            WeightsReader(W01, W12, W23, oneGenerationIteration);

            mobUpIteration = 0;
            OneMobLifeCycle.Start();
            OneGeneration.Stop();
        }
Ejemplo n.º 3
0
 private void GlobalCycle_Tick(object sender, EventArgs e)
 {
     for (int i = 0; i < mobScore.Length; i++)
     {
         mobScore[i] = 0;
     }
     oneGenerationIteration = 0;
     mutationRange         *= 0.99;
     label10.Text           = "Generation num: " + Convert.ToString(++generationNum);
     OneGeneration.Start();
     GlobalCycle.Stop();
 }
Ejemplo n.º 4
0
        private void OneMobLifeCycle_Tick(object sender, EventArgs e)
        {
            label11.Text = "Mob Up Iter: " + mobUpIteration;
            Intersect();
            //raysDistanceFact.CopyTo(L0, 0);
            L0[0] = raysDistanceFact[0];
            L0[1] = raysDistanceFact[1];
            L0[2] = raysDistanceFact[2];
            L0[3] = raysDistanceFact[3];
            L0[4] = raysDistanceFact[4];
            L0[5] = raysDistanceFact[5];
            L0[6] = raysDistanceFact[6];
            L0[7] = raysDistanceFact[7];

            Forward(L0, W01, L1);
            Forward(L1, W12, L2);
            Forward(L2, W23, L3);
            double maxRotateVal = Math.Max(L3[1], L3[2]);

            if (L3[0] > 0.5)
            {
                UpMoveDef();
            }

            if (maxRotateVal > 0.5 && Array.IndexOf(L3, maxRotateVal) != 0)
            {
                switch (Array.IndexOf(L3, maxRotateVal))
                {
                case 1:
                    LeftRotateDef();
                    break;

                case 2:
                    RightRotateDef();
                    break;

                default:
                    break;
                }
            }
            mobUpIteration++;

            if (mobUpIteration == 500) //время жизни одного моба
            {
                if (firstGenerationIteration != mobScore.Length + 1)
                {
                    mobScore[firstGenerationIteration] = score;
                    firstGenerationIteration++;
                    FirstGeneration.Start();
                }
                else if (oneGenerationIteration != mobScore.Length + 1)
                {
                    mobScore[oneGenerationIteration] = score;
                    oneGenerationIteration++;
                    OneGeneration.Start();
                }
                else
                {
                    GlobalCycle.Start();
                }

                MobRestart();
                OneMobLifeCycle.Stop();
            }
        }