public void move(int offset, int Yset, ref MobileRobot bots)
 {
     this.isMoving = true;
     for (int i = 1; i <= offset; i++)
     {
         this.X += 1;
         Thread.Sleep(100);
     }
     //  this.Y += Yset;
     this.isMoving = false;
 }
        public void distributeUniformly(ref List <MobileRobot> robots, ref List <int> cycles) // has to use or implement(modified)
        {
            Random      rand  = new Random();
            MobileRobot left  = new MobileRobot(this.X, -999);
            MobileRobot right = new MobileRobot(this.X, 999);

            while (true)
            {
                left.Y  = -9999;
                right.Y = 9999;
                foreach (MobileRobot r in robots)
                {
                    if (r.id != this.id)
                    {
                        if (r.Y > this.Y && r.Y < right.Y)
                        {
                            right.Y = r.Y;
                        }

                        if (r.Y < this.Y && r.Y > left.Y)
                        {
                            left.Y = r.Y;
                        }
                    }
                }

                int midY;
                if (left.Y == -9999)
                {
                    midY = this.Y;
                }
                else
                {
                    if (right.Y == 9999)
                    {
                        midY = this.Y;
                    }
                    else
                    {
                        midY = Math.Abs((left.Y + right.Y) / 2);
                    }
                }
                if (midY != this.Y)
                {
                    this.Y = midY;
                }

                cycles[id]++;
                counts++; // added number of moves
                Thread.Sleep(rand.Next(500, 5000));
                //Thread.Sleep(1000);
            }
        }