Пример #1
0
 public void reInit(object_seen a, object_seen b, object_seen c)
 {
     a.taken  = false;
     a.height = 2;
     b.taken  = false;
     b.height = 5;
     c.taken  = false;
     c.height = 7;
 }
Пример #2
0
 //checks if any of the objects given are empty
 public bool three_filled(object_seen a, object_seen b, object_seen c)
 {
     if (a.taken == true && b.taken == true && c.taken == true)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Пример #3
0
 public bool helperMethod(object_seen a, object_seen b, object_seen c, int x, int y)
 {
     if (a.taken == false)
     {
         if (a.height != b.height)
         {
             if (a.height != c.height)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Пример #4
0
        /*
         * initalizes the object_seen structs such that the taken value is false
         */
        public void init()
        {
            blue1 = new object_seen();
            blue2 = new object_seen();
            blue3 = new object_seen();
            reInit(blue1, blue2, blue3);

            red1 = new object_seen();
            red2 = new object_seen();
            red3 = new object_seen();
            reInit(red1, red2, red3);

            green1 = new object_seen();
            green2 = new object_seen();
            green3 = new object_seen();
            reInit(green1, green2, green3);
        }
Пример #5
0
 //compare size of objects and put them in an array from biggest to smallest.
 public object_seen[] findBiggest(object_seen a, object_seen b, object_seen c)
 {
     object_seen[] inOrder;
     inOrder = new object_seen[3];
     if (a.height > b.height)
     {
         if (b.height > c.height)
         {
             inOrder[0] = a;
             inOrder[1] = b;
             inOrder[2] = c;
         }
         else if (c.height > a.height)
         {
             inOrder[0] = c;
             inOrder[1] = a;
             inOrder[2] = b;
         }
     }
     else if (a.height > c.height)
     {
         inOrder[0] = b;
         inOrder[1] = a;
         inOrder[2] = c;
     }
     else if (b.height > c.height)
     {
         inOrder[0] = b;
         inOrder[1] = c;
         inOrder[2] = a;
     }
     else
     {
         inOrder[0] = c;
         inOrder[1] = b;
         inOrder[2] = a;
     }
     return(inOrder);
 }
Пример #6
0
        //figure out where each object is relative to the desired location.
        public void get_barring(object_seen a, object_seen b, object_seen c, int destinationX, int destinationY, bool d, String color)
        {
            if (d == false)
            {
                return;
            }
            bool isNull = three_filled(a, b, c);

            if (isNull == false)
            {
                //not all are filled
                //wait
                return;
            }
            else
            {
                //math stuff
                double distance_to_biggest;
                double distance_to_middle;
                double distance_to_smallest;

                distance_to_biggest  = System.Math.Sqrt(System.Math.Pow((c.xCoord - destinationX), 2.0) + System.Math.Pow((c.yCoord - destinationY), 2.0));
                distance_to_middle   = System.Math.Sqrt(System.Math.Pow((b.xCoord - destinationX), 2.0) + System.Math.Pow((b.yCoord - destinationY), 2.0));
                distance_to_smallest = System.Math.Sqrt(System.Math.Pow((a.xCoord - destinationX), 2.0) + System.Math.Pow((a.yCoord - destinationY), 2.0));

                if (positiveResult(distance_to_biggest, distance_to_middle) < 20 && positiveResult(distance_to_biggest, distance_to_smallest) < 20)
                {
                    if (color == "blue")
                    {
                        Bluedone = true;
                    }
                    else if (color == "red")
                    {
                        Reddone = true;
                    }
                    else if (color == "black")
                    {
                        Blackdone = true;
                    }
                    //at the destination
                    //stop
                }
                if (positiveResult(distance_to_middle, distance_to_smallest) < 25)
                {
                    if (distance_to_smallest < distance_to_biggest)
                    {
                        Console.WriteLine("go forward");
                        csclient.StartClient(color, "f");
                        //go forward
                    }
                    else
                    {
                        Console.WriteLine("long turn");
                        csclient.StartClient(color, "a");
                        //long turn
                    }
                }
                else
                {
                    if (distance_to_middle < distance_to_smallest)
                    {
                        Console.WriteLine("turn towards middle");
                        csclient.StartClient(color, "r");
                        //turn towards middle
                    }
                    else if (distance_to_smallest < distance_to_middle)
                    {
                        Console.WriteLine("turn towards smallest");
                        csclient.StartClient(color, "l");
                        //turn towards smallest
                    }
                }
            }
            reInit(a, b, c);
            return;
        }