Beispiel #1
0
 public void InitCompetitors()
 {
     for (int i = 0; i < numberOfCompetitors; i++)
     {
         Competitor c = GenerateRandomCompetitor();
         compQueue.Enqueue(c);
     }
 }
Beispiel #2
0
        private Competitor GenerateRandomCompetitor()
        {
            Competitor comp = new Competitor();

            comp.Rajtszam = 100 + COMP_COUNTER++;

            long hatralevoIdo = this.Length * 60 * 60 * 1000;   // hatralevo ido millisecundumban (kezdetben ez a verseny ideje)

            comp.Bejegyzesek = new List <Rekord>();

            comp.Bejegyzesek.Add(new Rekord(0, rnd.Next(96, 130)));

            float alaptempo     = (float)rnd.Next(250, 340) / 1000000;
            float freshness     = (float)rnd.Next(1100, 1200) / 1000;
            long  deadlock      = rnd.Next(500000, 1500000);
            float tiring        = (hatralevoIdo < deadlock ? (float)rnd.Next(5, 10) : 0) / 100000;
            float raceCondition = (float)((hatralevoIdo < deadlock - 300000) ? (float)rnd.Next(1100, 1200) / 1000 : (float)rnd.Next(900, 950) / 1000);

            int i = 1;

            while (hatralevoIdo > 0)
            {
                float ujTavolsag = 0;
                lock (tavolsagLock)
                {
                    ujTavolsag = (comp.Bejegyzesek[i - 1].tavolsag + (float)(alaptempo * freshness * raceCondition) * ((float)rnd.Next(980, 1020) / (100000 / timestep)));
                }
                int ujPulzus = (comp.Bejegyzesek[i - 1].pulse < 175 ? rnd.Next(comp.Bejegyzesek[i - 1].pulse - 1, comp.Bejegyzesek[i - 1].pulse + 3) : rnd.Next(comp.Bejegyzesek[i - 1].pulse - 2, comp.Bejegyzesek[i - 1].pulse + 2));
                comp.Bejegyzesek.Add(new Rekord(ujTavolsag, ujPulzus));
                freshness    -= tiring;
                hatralevoIdo -= this.Timestep;
                i++;
            }

            return(comp);
        }
Beispiel #3
0
 public void NextComp()
 {
     Comp = compQueue.Dequeue();
 }