public void BestPiece()
            {
                Bitmap picture     = new Bitmap("C:\\Bot\\testcars1\\test1.jpg");
                Bitmap picturetest = new Bitmap("C:\\Bot\\testcars3\\test1.jpg");

                int x0            = 32;
                int y0            = 7;
                int bestposx      = 0;
                int bestposy      = 0;
                int minshadesdifs = -1;

                for (int zeroposx = 0; zeroposx < 114 - 50; zeroposx++)
                {
                    for (int zeroposy = 0; zeroposy < 64 - 50; zeroposy++)
                    {
                        int shadesdifs0 = 0;
                        for (int x1 = 0; x1 < 50; x1++)
                        {
                            for (int y1 = 0; y1 < 50; y1++)
                            {
                                var colorValue0 = picture.GetPixel(x0 + x1, y0 + y1);
                                var colorValue1 = picturetest.GetPixel(zeroposx + x1, zeroposy + y1);
                                int shadesdifs1 = (Math.Abs((int)colorValue0.R - (int)colorValue1.R) +
                                                   Math.Abs((int)colorValue0.G - (int)colorValue1.G) +
                                                   Math.Abs((int)colorValue0.B - (int)colorValue1.B));
                                shadesdifs0 += shadesdifs1;
                            }
                        }
                        NotePad.DoErrorLog("стартовая позиция второй картинки " + zeroposx + " " + zeroposy + ", отличие " + shadesdifs0 + " оттенков");
                        if (minshadesdifs == -1 || minshadesdifs > shadesdifs0)
                        {
                            minshadesdifs = shadesdifs0;
                            bestposx      = zeroposx;
                            bestposy      = zeroposy;
                        }
                    }
                }

                NotePad.DoErrorLog("наиболее подходящий кусок " + bestposx + " " + bestposy + " с отличием в " + minshadesdifs + " оттенков");

                picture.Dispose();
                picturetest.Dispose();
            } //pay attention
            } //pay attention

            public void MapsofDifs()
            {
                Bitmap      picture     = new Bitmap("C:\\Bot\\testcars1\\test.jpg");
                Bitmap      picturetest = new Bitmap("C:\\Bot\\testcars5\\test.jpg");
                PixelFormat format      = PixelFormat.Format24bppRgb;
                Bitmap      Rmap        = new Bitmap(picture.Width, picture.Height, format);
                Bitmap      Gmap        = new Bitmap(picture.Width, picture.Height, format);
                Bitmap      Bmap        = new Bitmap(picture.Width, picture.Height, format);
                Bitmap      Noirmap     = new Bitmap(picture.Width, picture.Height, format);

                int rMaxShadesDifs    = 0;
                int gMaxShadesDifs    = 0;
                int bMaxShadesDifs    = 0;
                int noirMaxShadesDifs = 0;

                int rIdentical    = 0;
                int gIdentical    = 0;
                int bIdentical    = 0;
                int noirIdentical = 0;

                for (int x = 0; x < picture.Width; x++)
                {
                    for (int y = 0; y < picture.Height; y++)
                    {
                        var colorValue0 = picture.GetPixel(x, y);
                        var colorValue1 = picturetest.GetPixel(x, y);
                        Rmap.SetPixel(x, y, (Color.FromArgb(Math.Abs((int)colorValue0.R - (int)colorValue1.R) * 10, 255, 255)));
                        if (rMaxShadesDifs < Math.Abs((int)colorValue0.R - (int)colorValue1.R))
                        {
                            rMaxShadesDifs = Math.Abs((int)colorValue0.R - (int)colorValue1.R);
                        }
                        if ((int)colorValue0.R - (int)colorValue1.R == 0)
                        {
                            rIdentical++;
                        }

                        Gmap.SetPixel(x, y, (Color.FromArgb(255, Math.Abs((int)colorValue0.G - (int)colorValue1.G) * 10, 255)));
                        if (gMaxShadesDifs < Math.Abs((int)colorValue0.G - (int)colorValue1.G))
                        {
                            gMaxShadesDifs = Math.Abs((int)colorValue0.G - (int)colorValue1.G);
                        }
                        if ((int)colorValue0.G - (int)colorValue1.G == 0)
                        {
                            gIdentical++;
                        }

                        Bmap.SetPixel(x, y, (Color.FromArgb(255, 255, Math.Abs((int)colorValue0.B - (int)colorValue1.B) * 10)));
                        if (bMaxShadesDifs < Math.Abs((int)colorValue0.B - (int)colorValue1.B))
                        {
                            bMaxShadesDifs = Math.Abs((int)colorValue0.B - (int)colorValue1.B);
                        }
                        if ((int)colorValue0.B - (int)colorValue1.B == 0)
                        {
                            bIdentical++;
                        }

                        int noir = Math.Abs(((int)colorValue0.R + (int)colorValue0.G + (int)colorValue0.B) / 3 -
                                            ((int)colorValue1.R + (int)colorValue1.G + (int)colorValue1.B) / 3);
                        Noirmap.SetPixel(x, y, (Color.FromArgb(noir, noir, noir)));
                        if (noirMaxShadesDifs < noir)
                        {
                            noirMaxShadesDifs = noir;
                        }
                        if (noir == 0)
                        {
                            noirIdentical++;
                        }
                    }
                }

                NotePad.DoErrorLog("Максимальное отклонение красный " + rMaxShadesDifs);
                NotePad.DoErrorLog("Максимальное отклонение зеленый " + gMaxShadesDifs);
                NotePad.DoErrorLog("Максимальное отклонение синий " + bMaxShadesDifs);
                NotePad.DoErrorLog("Максимальное отклонение нуар " + noirMaxShadesDifs);

                NotePad.DoErrorLog("красные совпали " + rIdentical);
                NotePad.DoErrorLog("зеленые совпали " + gIdentical);
                NotePad.DoErrorLog("синие совпали " + bIdentical);
                NotePad.DoErrorLog("нуар совпали " + noirIdentical);

                Rmap.Save("C:\\Bot\\Maps\\Rmap.jpg", ImageFormat.Jpeg);
                Gmap.Save("C:\\Bot\\Maps\\Gmap.jpg", ImageFormat.Jpeg);
                Bmap.Save("C:\\Bot\\Maps\\Bmap.jpg", ImageFormat.Jpeg);
                Noirmap.Save("C:\\Bot\\Maps\\Noirmap.jpg", ImageFormat.Jpeg);

                Rmap.Dispose();
                Gmap.Dispose();
                Bmap.Dispose();
                Noirmap.Dispose();
                picture.Dispose();
                picturetest.Dispose();
            } //for fun
        public double CalculateCompatibility(string track, string coverage, string weather, Car car)
        {
            double x = 0;

            switch (coverage)
            {
            case "Асфальт":
                switch (weather)
                {
                case "Солнечно":
                    break;

                case "Дождь":
                    if (car.drive == 4)
                    {
                        x += 50;
                    }
                    switch (car.tires)
                    {
                    case 1:
                        x -= 500;
                        break;

                    case 2:
                        x -= 200;
                        break;

                    case 3:
                        x += 0;
                        break;

                    case 4:
                        x -= 100;
                        break;

                    case 5:
                        x += 500;
                        break;
                    }
                    break;

                default:
                    break;
                }
                break;

            case "Гравий":
                switch (car.tires)
                {
                case 1:
                    x -= 300;
                    break;

                case 2:
                    x -= 250;
                    break;

                case 3:
                    x += 100;
                    break;

                case 4:
                    x -= 50;
                    break;

                case 5:
                    x += 0;
                    break;
                }
                if (car.drive == 4)
                {
                    x += 100;
                }
                break;

            case "Грунт":
                switch (weather)
                {
                case "Солнечно":
                    switch (car.tires)
                    {
                    case 1:
                        x -= 400;
                        break;

                    case 2:
                        x -= 300;
                        break;

                    case 3:
                        x -= 200;
                        break;

                    case 4:
                        x -= 50;
                        break;

                    case 5:
                        x += 0;
                        break;
                    }
                    if (car.drive == 4)
                    {
                        x += 100;
                    }
                    break;

                case "Дождь":
                    switch (car.tires)
                    {
                    case 1:
                        x -= 1000;
                        break;

                    case 2:
                        x -= 800;
                        break;

                    case 3:
                        x -= 300;
                        break;

                    case 4:
                        x -= 100;
                        break;

                    case 5:
                        x += 0;
                        break;
                    }
                    if (car.drive == 4)
                    {
                        x += 200;
                    }
                    break;

                default:
                    break;
                }
                break;

            case "Песок":
                switch (car.tires)
                {
                case 1:
                    x -= 300;
                    break;

                case 2:
                    x -= 250;
                    break;

                case 3:
                    x -= 150;
                    break;

                case 4:
                    x -= 50;
                    break;

                case 5:
                    x += 0;
                    break;
                }
                if (car.drive == 4)
                {
                    x += 100;
                }
                break;

            case "Снег":
                switch (car.tires)
                {
                case 1:
                    x -= 1000;
                    break;

                case 2:
                    x -= 800;
                    break;

                case 3:
                    x -= 300;
                    break;

                case 4:
                    x -= 100;
                    break;

                case 5:
                    x += 0;
                    break;
                }
                if (car.drive == 4)
                {
                    x += 150;
                }
                break;

            case "Смешанное":
                switch (weather)
                {
                case "Солнечно":
                    switch (car.tires)
                    {
                    case 1:
                        x -= 300;
                        break;

                    case 2:
                        x -= 200;
                        break;

                    case 3:
                        x -= 0;
                        break;

                    case 4:
                        x -= 0;
                        break;

                    case 5:
                        x += 0;
                        break;
                    }
                    break;

                case "Дождь":
                    switch (car.tires)
                    {
                    case 1:
                        x -= 1000;
                        break;

                    case 2:
                        x -= 600;
                        break;

                    case 3:
                        x -= 300;
                        break;

                    case 4:
                        x -= 0;
                        break;

                    case 5:
                        x -= 300;
                        break;
                    }
                    break;

                default:
                    break;
                }
                if (car.drive == 4)
                {
                    x += 200;
                }
                break;

            case "Трава":
                switch (car.tires)
                {
                case 1:
                    x -= 1000;
                    break;

                case 2:
                    x -= 800;
                    break;

                case 3:
                    x -= 300;
                    break;

                case 4:
                    x -= 100;
                    break;

                case 5:
                    x += 0;
                    break;
                }
                if (car.drive == 4)
                {
                    x += 150;
                }
                break;

            case "Лед":
                switch (car.tires)
                {
                case 1:
                    x -= 1000;
                    break;

                case 2:
                    x -= 800;
                    break;

                case 3:
                    x -= 500;
                    break;

                case 4:
                    x -= 200;
                    break;

                case 5:
                    x += 0;
                    break;
                }
                if (car.drive == 4)
                {
                    x += 150;
                }
                break;
            }

            switch (track)
            {
            case "Длинная трасса у океана":
                x *= 2;
                x -= car.acceleration * 100;
                x -= car.grip * 5;
                x += car.weight / 10;
                x += car.maxSpeed;
                break;

            case "Короткая трасса у океана":
                x *= 2;
                x -= car.acceleration * 120;
                x -= car.grip * 5;
                x += car.weight / 10;
                x += car.maxSpeed / 2;
                break;

            case "Магистраль у океана":
                x *= 3;
                x += car.maxSpeed;
                x -= car.acceleration * 50;
                x += car.grip;
                break;

            case "Парковка у океана":
            case "Пляжный слалом у океана":
                x *= 4;
                x -= car.acceleration * 30;
                x += car.grip * 8;
                x -= car.weight;
                break;

            case "Городские улицы у океана":
            case "Улица ср":
            case "Улица мал":
                x *= 3;
                switch (car.clearance)
                {
                case 1:
                    x += 0;
                    break;

                case 2:
                    x += 700;
                    break;

                case 3:
                    x += 300;
                    break;
                }
                break;

            case "Подъем на холм":
                x *= 3;
                x -= car.acceleration * 50;
                if (coverage != "Асфальт")
                {
                    if (car.drive == 4)
                    {
                        x += 100;
                    }
                    switch (car.clearance)
                    {
                    case 1:
                        x += 0;
                        break;

                    case 2:
                        x += 200;
                        break;

                    case 3:
                        x += 500;
                        break;
                    }
                }
                break;

            case "Трасса для мотокросса":
                x *= 4;
                if (car.drive == 4)
                {
                    x += 50;
                }
                switch (car.clearance)
                {
                case 1:
                    x += 0;
                    break;

                case 2:
                    x += 200;
                    break;

                case 3:
                    x += 500;
                    break;
                }
                break;

            case "50-150":
                x *= 1;
                x -= car.acceleration * 100;
                x -= car.grip;
                x += car.weight / 10;
                x += car.maxSpeed * 10;
                if (car.maxSpeed < 150)
                {
                    x -= 2000;
                }
                break;

            case "75-125":
                x *= 1;
                x -= car.acceleration * 150;
                x -= car.grip;
                x += car.weight / 10;
                x += car.maxSpeed * 5;
                if (car.maxSpeed < 130)
                {
                    x -= 2000;
                }
                break;

            case "0-100":
                x *= 3;
                x -= car.acceleration * 200;
                x -= car.grip * 5;
                x += car.weight / 10;
                x += car.maxSpeed * 2;
                if (car.maxSpeed < 105)
                {
                    x -= 2000;
                }
                break;

            case "0-100-0":
                x *= 3.5;
                x -= car.acceleration * 100;
                x -= car.grip * 5;
                x += car.weight / 10;
                x += car.maxSpeed * 2;
                if (car.maxSpeed < 105)
                {
                    x -= 2000;
                }
                break;

            case "1":
                x *= 1.5;
                x -= car.acceleration * 80;
                x -= car.grip * 5;
                x += car.weight / 10;
                x += car.maxSpeed * 3;
                break;

            case "1/2":
                x *= 2.5;
                x -= car.acceleration * 100;
                x -= car.grip * 5;
                x += car.weight / 10;
                x += car.maxSpeed;
                break;

            case "1/4":
                x *= 3;
                x -= car.acceleration * 120;
                x -= car.grip * 5;
                x += car.weight / 10;
                x += car.maxSpeed / 2;
                break;

            case "0-60":
                x *= 4;
                x -= car.acceleration * 120;
                x -= car.grip * 5;
                x += car.weight / 10;
                if (car.maxSpeed < 60)
                {
                    x -= 2000;
                }
                break;

            case "Токио трасса":
            case "Трасса набережная":
                x *= 2;
                x -= car.acceleration * 100;
                x -= car.grip * 5;
                x += car.weight / 10;
                x += car.maxSpeed;
                break;

            case "Тестовый круг":
                x *= 1;
                x += car.maxSpeed * 5;
                x -= car.grip * 10;
                x += car.weight / 10;
                break;

            case "Токио мостик":
                x *= 3;
                x += car.maxSpeed * 3;
                x -= car.acceleration * 6;
                break;

            case "Нюрбург 1":
            case "Нюрбург 2":
            case "Нюрбург 3":
            case "Нюрбург 4":
            case "Нюрбург 5":
                x *= 2.5;
                x += car.maxSpeed * 3;
                break;

            case "Токио петля":
                x *= 2.5;
                x += car.maxSpeed * 2;
                x -= car.acceleration * 80;
                break;

            case "Замерзшее озеро":
                x *= 4;
                if (car.tires == 5)
                {
                    x += 500;
                }
                if (car.tires == 4)
                {
                    x += 200;
                }
                break;

            case "Горы серпантин":
                x *= 4;
                if (coverage != "Асфальт" || weather != "Солнечно")
                {
                    if (car.drive == 4)
                    {
                        x += 50;
                    }
                }
                break;

            case "Горы извилистая дорога":
                x *= 4;
                x -= car.acceleration * 30;
                x += car.grip * 4;
                break;

            case "Горы дорога с уклоном":
                x *= 3;
                x += car.maxSpeed;
                x -= car.acceleration * 50;
                x += car.grip;
                break;

            case "Горы подъем на холм":
                x *= 3;
                switch (car.clearance)
                {
                case 1:
                    x += 0;
                    break;

                case 2:
                    x += 200;
                    break;

                case 3:
                    x += 500;
                    break;
                }
                x -= car.acceleration * 50;
                x += car.grip;
                if (coverage != "Асфальт")
                {
                    if (car.drive == 4)
                    {
                        x += 200;
                    }
                }
                break;

            case "Горная экспедиция":
                x *= 2.5;
                x += car.maxSpeed;
                x += car.grip / 2;
                break;

            case "Извилистая дорога":
                x *= 4;
                if (coverage != "Асфальт")
                {
                    switch (car.clearance)
                    {
                    case 1:
                        x += 0;
                        break;

                    case 2:
                        x += 200;
                        break;

                    case 3:
                        x += 400;
                        break;
                    }
                    if (car.drive == 4)
                    {
                        x += 50;
                    }
                }
                break;

            case "Быстрая трасса":
                x *= 2.5;
                x -= car.acceleration * 40;
                x -= car.grip / 2;
                x += car.weight / 5;
                x += car.maxSpeed * 2;
                break;

            case "Highway":
                x *= 2.5;
                x -= car.acceleration * 40;
                x += car.weight / 5;
                x += car.grip * 2;
                x += car.maxSpeed;
                break;

            case "Монако длинные городские улицы":
                x *= 3;
                x -= car.acceleration * 40;
                x -= car.grip / 2;
                x += car.maxSpeed;
                break;

            case "Каньон экспедиция":
                x *= 2.5;
                x -= car.acceleration * 30;
                x -= car.grip / 4;
                x += car.maxSpeed;
                break;

            case "Серпантин":
            case "Монако серпантин":
                x *= 3.5;
                x -= car.acceleration * 50;
                x += car.grip;
                break;

            case "Извилистая трасса":
                x *= 3;
                x -= car.acceleration * 20;
                x += car.grip * 10;
                break;

            case "Токио мост":
            case "Токио съезд":
            case "Монако городские":
                x *= 3;
                x += car.maxSpeed * 2;
                x -= car.acceleration * 50;
                x += car.grip;
                break;

            case "Обзор":
                x *= 2.5;
                x += car.maxSpeed * 2;
                x -= car.acceleration * 50;
                x += car.grip;
                break;

            case "Каньон грунтовая дорога":
                x *= 2.5;
                x -= car.acceleration * 40;
                x += car.grip * 2;
                break;

            case "Каньон крутой холм":
                x *= 3;
                x -= car.acceleration * 40;
                x += car.grip * 2;
                break;

            case "Лесная переправа":
                x *= 3;
                x -= car.acceleration * 40;
                x += car.grip * 2;
                break;

            case "Ралли-кросс мал":
            case "Ралли-кросс ср":
                x *= 3;
                x -= car.acceleration * 40;
                x += car.grip * 2;
                break;

            case "Лесная дорога":
                x *= 3;
                x -= car.acceleration * 20;
                x += car.grip * 10;
                break;

            case "Монако узкие улицы":
                x *= 2.5;
                x -= car.acceleration * 40;
                x += car.grip * 5;
                x -= car.weight;
                break;

            case "Монако тест на перегрузки":
            case "Токио тест на перегрузки":
                x *= 4.5;
                x -= car.acceleration * 30;
                x += car.grip * 8;
                x -= car.weight;
                break;

            case "Трасса для картинга":
                x *= 4.5;
                x -= car.acceleration * 25;
                x += car.grip * 10;
                x -= car.weight;
                break;

            case "Парковка":
                x *= 5;
                x -= car.acceleration * 20;
                x += car.grip * 10;
                x -= car.weight * 2;
                break;

            case "Лесной слалом":
                x *= 5;
                x += car.grip * 10;
                x -= car.weight * 3;
                break;

            case "Закрытый картинг":
                x *= 5;
                x -= car.acceleration * 10;
                x += car.grip * 15;
                x -= car.weight * 3;
                break;

            case "Горы слалом":
                x *= 4.5;
                x += car.grip * 10;
                x -= car.weight * 3;
                break;

            case "Слалом":
                x *= 5;
                x += car.grip * 10;
                x -= car.weight * 3;
                break;

            case "Перегрузка":
                x *= 5;
                x -= car.acceleration * 10;
                x += car.grip * 15;
                x -= car.weight * 2;
                break;

            case "Неизвестная трасса":
                break;

            default:
                NotePad.DoErrorLog("Написать логику для " + track);
                break;
            }

            return(x);
        }