public Particle(Pooint position)
 {
     fitness         = 0;
     Current         = position;
     HistoryPositons = new List <Pooint>();
     HistoryBest     = position;
     Velocity        = new Pooint(GetRandomNum.GetIntNumber(0, 50), GetRandomNum.GetIntNumber(0, 50));
 }
Пример #2
0
        private void CalcOsobnikSpeed(Particle single, double inertia, double social, double coginitiv)
        {
            double R1        = GetRandomNum.GetDoubleNum();
            double R2        = GetRandomNum.GetDoubleNum();
            int    xVelocity = 0;
            int    yVelocity = 0;

            xVelocity         = (int)(inertia * single.Velocity.X + (coginitiv * R1 * (single.HistoryBest.X - single.Current.X)) + (social * R2 * (theBest.Current.X - single.Current.X)));
            yVelocity         = (int)(inertia * single.Velocity.Y + (coginitiv * R1 * (single.HistoryBest.Y - single.Current.Y)) + (social * R2 * (theBest.Current.Y - single.Current.Y)));
            single.Velocity.X = xVelocity;
            single.Velocity.Y = yVelocity;
        }
        private static List <Particle> MakeLudziki(Pooint SpawnOne, bool Choice)
        {
            List <Particle> Czastki    = new List <Particle>();
            int             jakiRodzaj = Choice ? iloscAut : iloscLudzikow;

            for (int i = 0; i < jakiRodzaj; i++)
            {
                int x = GetRandomNum.GetIntNumber(SpawnOne.X - 10, SpawnOne.X + 10);
                int y = GetRandomNum.GetIntNumber(SpawnOne.Y - 10, SpawnOne.Y + 10);
                if (Choice)
                {
                    Czastki.Add(new Car(new Pooint(x, y)));
                }
                else
                {
                    Czastki.Add(new Scout(new Pooint(x, y)));
                }
            }
            return(Czastki);
        }