public Domino(byte First, byte Second)
        {
            if (First > Second)
            {
                SwapClass.Swap(ref First, ref Second);
            }

            if (First > 6)
            {
                this.First = 6;
            }
            else if (First < 0)
            {
                this.First = 0;
            }
            else
            {
                this.First = First;
            }

            if (Second > 6)
            {
                this.Second = 6;
            }
            else if (Second < 0)
            {
                this.Second = 0;
            }
            else
            {
                this.Second = Second;
            }
        }
        public Domino(Image image)
        {
            byte First, Second;
            int  whiteCount = 0;

            for (int i = 0; i < image.Size.Height / 2; i++)
            {
                for (int j = 0; j < image.Size.Width / 2; j++)
                {
                    if ((image as Bitmap).GetPixel(i, j).R + (image as Bitmap).GetPixel(i, j).G + (image as Bitmap).GetPixel(i, j).B > 382.5)
                    {
                        whiteCount++;
                    }
                }
            }
            First      = (byte)(whiteCount / 6);
            whiteCount = 0;
            if (image.Height > image.Width)
            {
                for (int i = image.Size.Height / 2 + 1; i < image.Size.Height; i++)
                {
                    for (int j = 0; j < image.Size.Width / 2; j++)
                    {
                        if ((image as Bitmap).GetPixel(j, i).R + (image as Bitmap).GetPixel(j, i).G + (image as Bitmap).GetPixel(j, i).B > 384)
                        {
                            whiteCount++;
                        }
                    }
                }
            }
            else
            {
                for (int i = 0; i < image.Size.Height / 2; i++)
                {
                    for (int j = image.Size.Width / 2 + 1; j < image.Size.Width; j++)
                    {
                        if ((image as Bitmap).GetPixel(j, i).R + (image as Bitmap).GetPixel(j, i).G + (image as Bitmap).GetPixel(j, i).B > 384)
                        {
                            whiteCount++;
                        }
                    }
                }
            }
            Second     = (byte)(whiteCount / 6);
            whiteCount = 0;
            if (First > Second)
            {
                SwapClass.Swap(ref First, ref Second);
            }
            this.First  = First;
            this.Second = Second;
        }
Example #3
0
        public static void DoSort(ref ArrayClass arr, int first, int last)
        {
            int i = first;
            int j = last;
            int x = arr.Array[(first + last) / 2];

            do
            {
                while (arr.Array[i] < x)
                {
                    i++;
                }
                while (arr.Array[j] > x)
                {
                    j--;
                }

                if (i <= j)
                {
                    if (arr.Array[i] > arr.Array[j])
                    {
                        SwapClass.DoSwap(ref arr.Array[i], ref arr.Array[j]);
                    }
                    i++;
                    j--;
                }
            } while (i <= j);

            if (i < last)
            {
                DoSort(ref arr, i, last);
            }
            if (first < j)
            {
                DoSort(ref arr, first, j);
            }
        }
Example #4
0
 public SwapTest()
 {
     this.swap = new SwapClass();
 }