示例#1
0
文件: Animations.cs 项目: Kywi/Mamba
 public Animations(Form1 form1, Drowing draw_copy)
 {
     this.form1     = form1;
     this.draw_copy = draw_copy;
     this.picture   = (Bitmap)form1.DrawPanel.Image;
     elemnt_draw    = Graphics.FromImage(this.picture);
 }
示例#2
0
 public void Read_From_file(string filename)
 {
     try
     {
         string       ser = "";
         BinaryReader fin = new BinaryReader(new FileStream(filename, FileMode.Open));
         while (fin.BaseStream.Position != fin.BaseStream.Length)
         {
             ser = fin.ReadString();
         }
         fin.Close();
         Drowing temp = new Drowing(form1);
         temp = JsonConvert.DeserializeObject <Drowing>(ser);
         form1.cColunm_X.Value = temp.NColumnX;
         form1.cRows_Y.Value   = temp.NRowsY;
         form1.size_cell.Value = temp.CellSize;
         form1.Draw            = temp;
         form1.Draw.Form1      = form1;
         form1.DrawPanel.Image = new Bitmap(form1.DrawPanel.Width, form1.DrawPanel.Height);
         form1.Draw.Anim       = new Animations(form1, form1.Draw);
         form1.A = 3;
         form1.DrawPanel.Invalidate();
         form1.DrawPanel.Update();
     }
     catch (IOException x)
     {
         MessageBox.Show("Файл пошкоджено! Оберіть інший файл.", "Помилка", MessageBoxButtons.OK, MessageBoxIcon.Error);
         form1.A = 1;
         form1.DrawPanel.Invalidate();
         form1.DrawPanel.Update();
     }
 }
示例#3
0
        //пеервірка на чи можна прорубувати отвір в 4-ох напрямках від поточної точки
        private void check_neibours(int x, int y, char side)
        {
            int _y = 0, _x = 0, _z = 0;

            switch (side)
            {
            case 'U':
                _y = y - 2;
                if (_y < 0)
                {
                    return;
                }
                _x = x;
                break;

            case 'D':
                _y = y + 2;
                if (_y >= draw_copy.NRowsY)
                {
                    return;
                }
                _x = x;
                break;

            case 'L':
                _x = x - 2;
                if (_x < 0)
                {
                    return;
                }
                _y = y;
                break;

            case 'R':
                _x = x + 2;
                if (_x >= draw_copy.NColumnX)
                {
                    return;
                }
                _y = y;
                break;
            }
            _z = Drowing.Absol_Coord(_y, _x, draw_copy.NColumnX);
            if (draw_copy.Map[_z])
            {
                return;
            }
            if (draw_copy.Processed_cells[_z] != 0)
            {
                return;
            }
            neibor.Add(new neibours(new Ppoint(_x, _y, _z), side));
        }
示例#4
0
 protected override void init_mas()
 {
     draw_copy.init_drowing(2);
     for (int i = 0; i < draw_copy.NColumnX; i++)
     {
         for (int j = 0; j < draw_copy.NRowsY; j++)
         {
             if (((i % 2) == 0) || ((j % 2) == 0))
             {
                 draw_copy.Map[Drowing.Absol_Coord(j, i, draw_copy.NColumnX)] = true;
             }
         }
     }
 }
示例#5
0
文件: Animations.cs 项目: Kywi/Mamba
        public Bitmap getBlack_WhiteImage()
        {
            Bitmap   black_whiteIMG = new Bitmap(form1.DrawPanel.Width, form1.DrawPanel.Height);
            Graphics backWhite      = Graphics.FromImage(black_whiteIMG);

            for (int x = 0; x < draw_copy.NColumnX; x++)
            {
                for (int y = 0; y < draw_copy.NRowsY; y++)
                {
                    int z;
                    z = Drowing.Absol_Coord(y, x, draw_copy.NColumnX);
                    int Cell_X, Cell_Y;
                    Cell_X = x * draw_copy.CellSize;
                    Cell_Y = y * draw_copy.CellSize;
                    backWhite.FillRectangle(draw_copy.Map[z] ? new SolidBrush(Color.Black) : new SolidBrush(Color.White),
                                            new Rectangle(Cell_X, Cell_Y, draw_copy.CellSize, draw_copy.CellSize));
                }
            }

            return(black_whiteIMG);
        }
示例#6
0
文件: Animations.cs 项目: Kywi/Mamba
        //Визначення кольору який потрібен дял данної комірки за наявносто тільки координат данної комірки
        public void chek_colour(int x, int y)
        {
            int z, circuit = 0;

            z = Drowing.Absol_Coord(y, x, draw_copy.NColumnX);
            if (z == draw_copy.Start_point.z)
            {
                circuit = (draw_copy.Closed_cell[z] != 0) ?  2 : 0;
                draw_Cells(x, y, 3, circuit);
                return;
            }
            if (z == draw_copy.Finish_point.z)
            {
                circuit = (draw_copy.Closed_cell[z] != 0) ? 2 : 0;
                draw_Cells(x, y, 4, circuit);
                return;
            }
            if (z == draw_copy.Check_point.z)//Якщо комірка є аналізуючою
            {
                draw_Cells(x, y, 5, 1);
                return;
            }
            if (draw_copy.Map[z])//Якщо комірка є стіною
            {
                draw_Cells(x, y, 1);
                return;
            }
            if (draw_copy.Processed_cells[z] == draw_copy.Step)//Якщо данну комріку ми перевіряємо
            {
                draw_Cells(x, y, 6);
                return;
            }
            if (draw_copy.Processed_cells[z] != 0)//Якщо комірка є обробленою
            {
                circuit = (draw_copy.Closed_cell[z] != 0) ? 2 : 0;
                draw_Cells(x, y, 5, circuit);
                return;
            }
            draw_Cells(x, y, 2);
        }
示例#7
0
        public void recogn_Picture(string fileName)
        {
            Image <Bgr, Byte> img = null;

            img = new Image <Bgr, byte>(fileName);
            //  img._SmoothGaussian(7);
            Image <Gray, Byte> gr_img = img.Convert <Gray, Byte>();//ковнвертування в сірий колір

            gr_img = gr_img.ThresholdBinary(new Gray(150), new Gray(255));
            int w_b, h_b;

            gr_img = gr_img.Resize(form1.DrawPanel.Width, form1.DrawPanel.Height, Emgu.CV.CvEnum.Inter.Linear, true);
            int yr = gr_img.Height / 10,
                xc = gr_img.Width / 10;                                            // підгонка розмірів робочої області

            gr_img = gr_img.Resize(xc * 10, yr * 10, Emgu.CV.CvEnum.Inter.Linear); //маштабуємо розмір картинки
            form1.size_cell.Value = 10;
            form1.cColunm_X.Value = xc;
            form1.cRows_Y.Value   = yr;
            form1.DrawPanel.Update();
            w_b = gr_img.Width / (int)form1.cColunm_X.Value;
            h_b = gr_img.Height / (int)form1.cRows_Y.Value;

            for (int i = 0; i < form1.cRows_Y.Value; i++)//розпізнавання лабіринту на картинці
            {
                int ki = (i == 0) ? 0 : 1;
                for (int j = 0; j < form1.cColunm_X.Value; j++)
                {
                    int kj = (j == 0) ? 0 : 1;
                    gr_img.ROI = new Rectangle(j * w_b + kj, i * h_b + ki, (int)w_b, (int)h_b);
                    double avr_brit = gr_img.GetAverage().MCvScalar.V0;//отримання середньої якрості області
                    form1.Draw.Map[Drowing.Absol_Coord(i, j, form1.Draw.NColumnX)] = (avr_brit < 240);
                }
            }
            form1.update_screen();
        }
示例#8
0
文件: Algorithm_A.cs 项目: Kywi/Mamba
        public override void Path_Finding()
        {
            if (draw_copy.Start_point.z == -1 || draw_copy.Finish_point.z == -1)
            {
                MessageBox.Show("Встановіть старт та фініш", "Помилка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                form1.lock_buttons();
                form1.Hide_load_form();
                return;
            }

            int find_step = 0;

            First_Step();
            bool flag_find_step = true;

            while (open_Cells.Count != 0)//Початок знаходження шляху
            {
                Mode = form1.Flag_radioButtons;
                open_Cells.Sort((x, y) => x.F.CompareTo(y.F));
                struct_open_cell work_cell = open_Cells[0];
                open_Cells.RemoveAt(0);
                draw_copy.Closed_cell[work_cell.point.z] = work_cell.parent_cell.z;//Кладемо в текущу комірку ту з якої прийшли
                draw_copy.Check_point = work_cell.point;

                //Перевірка по 4 чи по 8 напрямкам
                for (int i = 0; i < 4; i++)
                {
                    Side_checker(work_cell, Mas_OF_sides[i]);
                }

                if (form1.checkBox2.Checked)
                {
                    for (int i = 4; i < 8; i++)
                    {
                        Side_checker(work_cell, Mas_OF_sides[i]);
                    }
                }
                if ((draw_copy.Closed_cell[draw_copy.Finish_point.z] != 0) && (draw_copy.Step != 2))//Перевірка чи не кінець
                {
                    if (flag_find_step)
                    {
                        find_step      = draw_copy.Step;
                        flag_find_step = false;
                    }
                    if (form1.checkBox1.Checked)
                    {
                        form1.visualisation_mode(Mode, form1, 1);
                        open_Cells.Clear();
                        break;
                    }
                }
                form1.textBox1.Text = Convert.ToString(draw_copy.Step);
                form1.visualisation_mode(Mode, form1, 1);
                draw_copy.Step++;
            }

            form1.textBox1.Text = Convert.ToString(draw_copy.Step);
            if (find_step != 0)//Побудова зворотнього шялху якщо він взвгвлі є
            {
                Stack <Ppoint> way_back = new Stack <Ppoint>();
                way_back.Push(draw_copy.Finish_point);
                int previous_element = draw_copy.Closed_cell[draw_copy.Finish_point.z];

                while (way_back.Peek() != draw_copy.Start_point)//Шлях назад
                {
                    int x = 0, y = 0;
                    Drowing.Reference_to_XY(ref x, ref y, previous_element, draw_copy.NColumnX);
                    way_back.Push(new Ppoint(x, y, previous_element));//Накидуєтсья масив точок для результуючого шляху
                    previous_element = draw_copy.Closed_cell[previous_element];
                }
                draw_copy.Anim.draw_way(way_back);
                form1.update_panel_without_redraw();
                form1.Hide_load_form();
                draw_copy.Show_Step(find_step);
            }
            else
            {
                form1.Hide_load_form();
                MessageBox.Show("Шлях не знайдено", "Повідомелння", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            Reset_Values();
        }
示例#9
0
        private void Side_checker(struct_open_cell work_cell, string side)
        {
            int _y = 0, _x = 0, _z = 0, _h = 0;
            int x = work_cell.point.x;
            int y = work_cell.point.y;

            switch (side)
            {
            case "U":
                _y = y - 1;
                if (_y < 0)
                {
                    return;
                }
                _x = x;
                break;

            case "D":
                _y = y + 1;
                if (_y >= draw_copy.NRowsY)
                {
                    return;
                }
                _x = x;
                break;

            case "L":
                _x = x - 1;
                if (_x < 0)
                {
                    return;
                }
                _y = y;
                break;

            case "R":
                _x = x + 1;
                if (_x >= draw_copy.NColumnX)
                {
                    return;
                }
                _y = y;
                break;

            case "LU":
                _x = x - 1;
                _y = y - 1;
                if (_x < 0 || _y < 0 || draw_copy.Map[Drowing.Absol_Coord(y, _x, draw_copy.NColumnX)] ||
                    draw_copy.Map[Drowing.Absol_Coord(_y, x, draw_copy.NColumnX)])
                {
                    return;
                }
                break;

            case "LD":
                _x = x - 1;
                _y = y + 1;
                if (_x < 0 || _y >= draw_copy.NRowsY || draw_copy.Map[Drowing.Absol_Coord(y, _x, draw_copy.NColumnX)] ||
                    draw_copy.Map[Drowing.Absol_Coord(_y, x, draw_copy.NColumnX)])
                {
                    return;
                }
                break;

            case "RU":
                _x = x + 1;
                _y = y - 1;
                if (_x >= draw_copy.NColumnX || _y < 0 || draw_copy.Map[Drowing.Absol_Coord(y, _x, draw_copy.NColumnX)] ||
                    draw_copy.Map[Drowing.Absol_Coord(_y, x, draw_copy.NColumnX)])
                {
                    return;
                }
                break;

            case "RD":
                _x = x + 1;
                _y = y + 1;
                if (_x >= draw_copy.NColumnX || _y >= draw_copy.NRowsY ||
                    draw_copy.Map[Drowing.Absol_Coord(y, _x, draw_copy.NColumnX)] ||
                    draw_copy.Map[Drowing.Absol_Coord(_y, x, draw_copy.NColumnX)])
                {
                    return;
                }
                break;
            }
            _z = Drowing.Absol_Coord(_y, _x, draw_copy.NColumnX);
            if (draw_copy.Map[_z])
            {
                return;
            }

            if (draw_copy.Closed_cell[_z] != 0)
            {
                return;
            }

            _h = hevristic_funct(_x, _y, draw_copy.Finish_point.x, draw_copy.Finish_point.y);
            int index_result = open_Cells.FindIndex(cell => cell.point.z.Equals(_z));

            if (index_result == -1)
            {
                open_Cells.Add(new struct_open_cell(_x, _y, _z, _h, work_cell.point));
                draw_copy.Processed_cells[_z] = draw_copy.Step;
            }
        }
示例#10
0
        //-----------------------------------------------

        public Algorithm_Best_F(Form1 form1, Drowing draw_copy) : base(form1, draw_copy)
        {
        }
示例#11
0
        public override void Path_Finding()
        {
            if (draw_copy.Start_point.z == -1 || draw_copy.Finish_point.z == -1)
            {
                MessageBox.Show("Встановіть старт та фініш", "Помилка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                form1.lock_buttons();
                form1.Hide_load_form();
                return;
            }

            int find_step = 0;

            First_Step();
            bool flag_find_step = true;

            while (open_Cells.Count != 0)
            {
                Mode = form1.Flag_radioButtons;
                open_Cells.Sort((x, y) => x.H.CompareTo(y.H));
                struct_open_cell work_cell = open_Cells[0];
                open_Cells.RemoveAt(0);
                draw_copy.Closed_cell[work_cell.point.z] = work_cell.parent_cell.z;
                draw_copy.Check_point = work_cell.point;

                for (int i = 0; i < 4; i++)
                {
                    Side_checker(work_cell, Mas_OF_sides[i]);
                }

                if (form1.checkBox2.Checked)
                {
                    for (int i = 4; i < 8; i++)
                    {
                        Side_checker(work_cell, Mas_OF_sides[i]);
                    }
                }
                if ((draw_copy.Closed_cell[draw_copy.Finish_point.z] != 0) && (draw_copy.Step != 2))
                {
                    if (flag_find_step)
                    {
                        find_step      = draw_copy.Step;
                        flag_find_step = false;
                    }
                    if (form1.checkBox1.Checked)
                    {
                        form1.visualisation_mode(Mode, form1, 1);
                        open_Cells.Clear();
                        break;
                    }
                }
                form1.textBox1.Text = Convert.ToString(draw_copy.Step);
                form1.visualisation_mode(Mode, form1, 1);
                draw_copy.Step++;
            }
            form1.textBox1.Text = Convert.ToString(draw_copy.Step);
            if (find_step != 0)
            {
                Stack <Ppoint> way_back = new Stack <Ppoint>();
                way_back.Push(draw_copy.Finish_point);
                int previous_element = draw_copy.Closed_cell[draw_copy.Finish_point.z];

                while (way_back.Peek() != draw_copy.Start_point)
                {
                    int x = 0, y = 0;
                    Drowing.Reference_to_XY(ref x, ref y, previous_element, draw_copy.NColumnX);
                    way_back.Push(new Ppoint(x, y, previous_element));
                    previous_element = draw_copy.Closed_cell[previous_element];
                }
                draw_copy.Anim.draw_way(way_back);
                form1.update_panel_without_redraw();
                draw_copy.Show_Step(find_step);
            }
            else
            {
                form1.Hide_load_form();

                MessageBox.Show("Шлях не знайдено", "Повідомелння", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            Reset_Values();
            form1.Hide_load_form();
        }
示例#12
0
        //-------------------------------------------------------------

        public Recognition_pict(Form1 form1, Drowing draw_copy)
        {
            this.form1     = form1;
            this.draw_copy = draw_copy;
        }
示例#13
0
        //------------------------------------------------

        public GenerationAI(Form1 form1, Drowing draw_copy) : base(form1, draw_copy)
        {
        }
示例#14
0
        public override void create_Labyrithm()
        {
            init_mas();
            draw_copy.Step = 2;
            Random rand = new Random();

            temp = new Ppoint(1, 1, Drowing.Absol_Coord(1, 1, draw_copy.NColumnX));
            neibours nt;
            int      _y = 0, _x = 0, _z = 0;

            draw_copy.Processed_cells[Drowing.Absol_Coord(1, 1, draw_copy.NColumnX)] = draw_copy.Step;
            chain_cells.Push(temp);
            draw_copy.Check_point = temp;
            form1.visualisation_mode(mode, form1, 1);

            while (chain_cells.Count != 0)//початок генерації
            {
                Mode = form1.Flag_radioButtons;
                temp = chain_cells.Peek();
                draw_copy.Check_point = temp;
                neibor.Clear();
                foreach (char tem in Mas_OF_sides)
                {
                    check_neibours(temp.x, temp.y, tem);
                }
                if (neibor.Count == 0)
                {
                    chain_cells.Pop();
                    form1.visualisation_mode(mode, form1);
                    continue;
                }
                nt = neibor[rand.Next(0, neibor.Count)];//обриаємо випадкову сторону сере доступних
                switch (nt.side)
                {
                case 'U':
                    _y = temp.y - 1;
                    _x = temp.x;
                    break;

                case 'D':
                    _y = temp.y + 1;
                    _x = temp.x;
                    break;

                case 'L':
                    _y = temp.y;
                    _x = temp.x - 1;
                    break;

                case 'R':
                    _y = temp.y;
                    _x = temp.x + 1;
                    break;
                }
                _z = Drowing.Absol_Coord(_y, _x, draw_copy.NColumnX);
                draw_copy.Map[_z]                 = false;//прорубуємо стінку
                draw_copy.Processed_cells[_z]     = draw_copy.Step - 1;
                draw_copy.Processed_cells[nt.p.z] = draw_copy.Step;

                form1.visualisation_mode(mode, form1, 1);
                chain_cells.Push(nt.p);
                draw_copy.Step++;
            }
            Reset_values();
        }
示例#15
0
文件: Algorithm_A.cs 项目: Kywi/Mamba
        private void Side_checker(struct_open_cell work_cell, string side)
        {
            int _y = 0, _x = 0, _z = 0, _h = 0, _f = 0;
            int x = work_cell.point.x;
            int y = work_cell.point.y;
            int g = work_cell.G;

            switch (side)
            {
            case "U":
                _y = y - 1;
                if (_y < 0)
                {
                    return;
                }
                _x = x;
                g += 10;
                break;

            case "D":
                _y = y + 1;
                if (_y >= draw_copy.NRowsY)
                {
                    return;
                }
                _x = x;
                g += 10;
                break;

            case "L":
                _x = x - 1;
                if (_x < 0)
                {
                    return;
                }
                _y = y;
                g += 10;
                break;

            case "R":
                _x = x + 1;
                if (_x >= draw_copy.NColumnX)
                {
                    return;
                }
                _y = y;
                g += 10;
                break;

            case "LU":
                _x = x - 1;
                _y = y - 1;
                g += 14;
                if (_x < 0 || _y < 0 || draw_copy.Map[Drowing.Absol_Coord(y, _x, draw_copy.NColumnX)] ||
                    draw_copy.Map[Drowing.Absol_Coord(_y, x, draw_copy.NColumnX)])
                {
                    return;
                }
                break;

            case "LD":
                _x = x - 1;
                _y = y + 1;
                g += 14;
                if (_x < 0 || _y >= draw_copy.NRowsY || draw_copy.Map[Drowing.Absol_Coord(y, _x, draw_copy.NColumnX)] ||
                    draw_copy.Map[Drowing.Absol_Coord(_y, x, draw_copy.NColumnX)])
                {
                    return;
                }
                break;

            case "RU":
                _x = x + 1;
                _y = y - 1;
                g += 14;
                if (_x >= draw_copy.NColumnX || _y < 0 || draw_copy.Map[Drowing.Absol_Coord(y, _x, draw_copy.NColumnX)] ||
                    draw_copy.Map[Drowing.Absol_Coord(_y, x, draw_copy.NColumnX)])
                {
                    return;
                }
                break;

            case "RD":
                _x = x + 1;
                _y = y + 1;
                g += 14;
                if (_x >= draw_copy.NColumnX || _y >= draw_copy.NRowsY ||
                    draw_copy.Map[Drowing.Absol_Coord(y, _x, draw_copy.NColumnX)] ||
                    draw_copy.Map[Drowing.Absol_Coord(_y, x, draw_copy.NColumnX)])
                {
                    return;
                }
                break;
            }
            _z = Drowing.Absol_Coord(_y, _x, draw_copy.NColumnX);
            if (draw_copy.Map[_z])
            {
                return;
            }

            if (draw_copy.Closed_cell[_z] != 0)
            {
                return;
            }

            _h = hevristic_funct(_x, _y, draw_copy.Finish_point.x, draw_copy.Finish_point.y);
            _f = g + _h;                                                              //Оціночне значення яке складається з суми ваг комірок + зачення еврестичної функції
            int index_result = open_Cells.FindIndex(cell => cell.point.z.Equals(_z)); //перевірка чи є вже така комріка, щоб не було дуплікатів

            if (index_result == -1)
            {
                open_Cells.Add(new struct_open_cell(_x, _y, _z, g, _h, _f, work_cell.point));
                draw_copy.Processed_cells[_z] = draw_copy.Step;
            }
            else
            {
                if (open_Cells[index_result].G > g)//Якщо комірка вже існує перервіряємо чи ми прийшли до неї з меншим G
                {
                    struct_open_cell temp_add = open_Cells[index_result];
                    temp_add.G               = g;
                    temp_add.F               = temp_add.H + g;
                    temp_add.parent_cell     = work_cell.point;
                    open_Cells[index_result] = temp_add;
                }
            }
        }
示例#16
0
        //-------------------------------------------------------------

        public Generation_By_Dividon(Form1 form1, Drowing draw_copy) : base(form1, draw_copy)
        {
        }
示例#17
0
        public override void create_Labyrithm()
        {
            init_mas();
            Random rx = new Random();
            Random ry = new Random();

            Rect_Points.Push(new rect_point(0, 0, draw_copy.NColumnX - 1, draw_copy.NRowsY - 1));
            bool flag_reverse = true;

            while (Rect_Points.Count != 0)
            {
                Mode = form1.Flag_radioButtons;
                temp = Rect_Points.Pop();
                int X_Numb_of_dividion, Y_Numb_of_dividion;
                X_Numb_of_dividion = (temp.P2.x - temp.P1.x) / 2 - 1;
                Y_Numb_of_dividion = (temp.P2.y - temp.P1.y) / 2 - 1;
                if ((X_Numb_of_dividion == 0) || (Y_Numb_of_dividion == 0))
                {
                    continue;
                }
                int x0, y0; // претин ліній ділення
                int rt = 0; //випадкове зачення
                int rk = ry.Next(Y_Numb_of_dividion - 1) + 1;
                if ((X_Numb_of_dividion / Y_Numb_of_dividion) >= 2)
                {
                    rt = rx.Next(Convert.ToInt32(Math.Round(X_Numb_of_dividion * 0.3)), Convert.ToInt32(Math.Round(X_Numb_of_dividion * 0.7)));
                }
                else
                {
                    rt = rx.Next(X_Numb_of_dividion - 1) + 1;
                }
                x0 = temp.P1.x + rt * 2;
                y0 = temp.P1.y + rk * 2;
                //області які отримуємо пілся ділення
                Rect_Points.Push(new rect_point(temp.P1.x, temp.P1.y, x0, y0));
                Rect_Points.Push(new rect_point(x0, temp.P1.y, temp.P2.x, y0));
                Rect_Points.Push(new rect_point(x0, y0, temp.P2.x, temp.P2.y));
                Rect_Points.Push(new rect_point(temp.P1.x, y0, x0, temp.P2.y));

                for (int i = temp.P1.x; i < temp.P2.x; i++)
                {
                    draw_copy.Map[Drowing.Absol_Coord(y0, i, draw_copy.NColumnX)] = true;
                }

                for (int j = temp.P1.y; j < temp.P2.y; j++)
                {
                    draw_copy.Map[Drowing.Absol_Coord(j, x0, draw_copy.NColumnX)] = true;
                }

                form1.visualisation_mode(mode, form1, 1);

                //отвори в цих областях
                List <hole> h = new List <hole>();
                h.Add(new hole((y0 - temp.P1.y) / 2, Mas_OF_sides[0]));
                h.Add(new hole((temp.P2.y - y0) / 2, Mas_OF_sides[1]));
                h.Add(new hole((x0 - temp.P1.x) / 2, Mas_OF_sides[2]));
                h.Add(new hole((temp.P2.x - x0) / 2, Mas_OF_sides[3]));

                //покращення рандомізації
                if (flag_reverse)
                {
                    h.Reverse();
                }

                //прорубування отворів
                h.Sort((x, y) => y.count_holes.CompareTo(x.count_holes));
                for (int i = 0; i < h.Count - 1; i++)
                {
                    rt = rx.Next(1, h[i].count_holes);
                    int _y = 0, _x = 0;
                    switch (h[i].side)
                    {
                    case 'U':
                        _y = y0 - (rt * 2 - 1);
                        _x = x0;
                        break;

                    case 'D':
                        _y = y0 + rt * 2 - 1;
                        _x = x0;
                        break;

                    case 'L':
                        _x = x0 - (rt * 2 - 1);
                        _y = y0;
                        break;

                    case 'R':
                        _x = x0 + rt * 2 - 1;
                        _y = y0;
                        break;
                    }
                    draw_copy.Map[Drowing.Absol_Coord(_y, _x, draw_copy.NColumnX)] = false;
                }
                form1.visualisation_mode(mode, form1, 1);
                flag_reverse = !flag_reverse;
            }
            Reset_values();
        }