private void ComparePerformances(Bot singleThreadBot, Bot multiThreadBot, Rocket initialRocket, int times = 40)
        {
            var successes = 0;
            var stopWatch = new Stopwatch();

            for (var i = 0; i < times; ++i)
            {
                stopWatch.Restart();
                singleThreadBot.GetNextMove(initialRocket);
                stopWatch.Stop();
                var singleThreadBotTime = stopWatch.Elapsed;
                stopWatch.Restart();
                multiThreadBot.GetNextMove(initialRocket);
                stopWatch.Stop();
                var multiThreadBotTime = stopWatch.Elapsed;
                if (multiThreadBotTime < singleThreadBotTime)
                {
                    ++successes;
                }
            }

            Assert.GreaterOrEqual(successes, 0.8 * times,
                                  $"Ваше решение в два потока должно работать быстрее решения в один поток в {times * 0.8} случаев из {times}");
        }
 public void Init()
 {
     random  = new Random(223243);
     channel = new Channel <Rocket>();
     rocket  = new Rocket(new Vector(100, 100), Vector.Zero, -0.5 * Math.PI);
 }
Exemple #3
0
 public Level(Rocket rocket, Vector[] checkpoints, Physics physics)
 {
     InitialRocket = rocket;
     Checkpoints   = checkpoints;
     Physics       = physics;
 }
Exemple #4
0
 private double GetDistanceToNextCheckpoint(Rocket rocket)
 {
     return((rocket.Location - rocket.GetNextRocketCheckpoint(level)).Length);
 }
Exemple #5
0
 public Task <Tuple <Turn, double> > GetBestPath(Rocket rocket)
 {
     return(Task.Run(() => SearchBestMove(rocket, new Random(random.Next()), iterationsCount / threadsCount)));
 }