Checkers_Prof_v01

Author: Inkov Evgeni
Miscellaneous
It writes information to fileIt reads information from a fileUses files from the file system
0 Views
0 Downloads
0 Favorites
Checkers_Prof_v01
ÿþ//+------------------------------------------------------------------+

//|                                            Checkers_Prof_v01.mq4 |

//+------------------------------------------------------------------+

#property copyright "Inkov Evgeni"

#property link      "ew123@mail.ru"

#property description "            !45;0=K 4>@01>B:8:"

#property description "1.>A;5 22>40 =072.D09;0, 4;O 70?8A8 <>6=> <KH:>9 =060BL =0 Save, => <>6=> ?@>AB> =060BL 420 @070 Enter (?5@2K9 Enter 70:0=G8205B 22>4, 2B>@>9 =068<05B =0 :=>?:C Save)"

#property description " "

#property description "2.@8 ?5@5E>45 2 @568< Set, AB8@05BAO 2AQ ?>;5 8 2A5 <8:@>?>78F88 (CAB.2E.?0@0<5B@><-true/false)"

#property description " "

#property description "3.@8 70?8A8 D09;0 A '+', C40;O5BAO >4=>8<5==K9 D09; 157 '+' (CAB.2E.?0@0<5B@><-true/false)"

//+------------------------------------------------------------------+

#property version   "2.00"

#property strict

//+------------------------------------------------------------------+

#define White_victory  100 // 15;K5  ?>1548;8

#define Black_victory -100 // G5@=K5 ?>1548;8

#define Clear_inf        0 // >G8AB8BL 8=D>@<0F8N

#define sum_micro_pos   10 // <0:A.:>;. 70?><=5==KE <8:@>?>78F89

#define max_sum_files   15 // <0:A.:>;. D09;>2 =0 M:@0=5

#define max_sum_dir     10 // <0:A.:>;. ?0?>: =0 M:@0=5

//+------------------------------------------------------------------+

int  shift_panel=0; // A4283 ?0=5;8

//+------------------------------------------------------------------+

enum lang

{

   rus=0,

   lat=1

};

//+------------------------------------------------------------------+

input lang language_inf=rus;

input bool clean_all_in_set=false; // >G8AB8BL ?>;5 8 <8:@>?>7. ?@8 Set

input bool del_no_plus_save_plus=false; // ?@8 70?.D09;0 A "+",C40;8BL 157 "+" 

//+------------------------------------------------------------------+

enum type_move // B8? E>40

{

   off =-1,  // =5B 8=D>@<0F88 > B8?5 E>40

   no  = 0,  // C H0H:8 =5B 2>7<>6=>AB8 4;O E>40

   let = 1,  // 4>?CAB8<K9 E>4

   beg = 2,  // =0G0;L=0O G0ABL E>40

};

enum type_ch // B8? H0H:8

{

   OFF=-1, // :;5B:0 70 ?@545;0<8 83@>2>3> ?>;O

               // 2 ?>;5:

   NO = 0, // =5B H0H:8

   

   pW = 2, // ?@>AB0O(p) 15;0O (White)

   dW = 3, // 40<:0(d) 15;0O

   pWr= 4, // ?@>AB0O 15;0O A@C1;5==0O(r)

   dWr= 5, // 40<:0 15;0O A@C1;5==0O

   

   pB =-2, // ?@>AB0O G5@=0O (Black)

   dB =-3, // 40<:0 G5@=0O

   pBr=-4, // ?@>AB0O G5@=0O A@C1;5==0O

   dBr=-5  // 40<:0 G5@=0O A@C1;5==0O

};

color clr_Text     =clrWhite;

color clr_Text_but =clrBlack;

color clr_Osn      =clrIndianRed;

color clr_Fon      =clrLightGray;

color clr_Fon_off  =clrDimGray;

color clr_Fon_But  =clrYellow;

color clr_Fon_But1 =clrMagenta;

color clr_Arrow    =clrDarkSlateGray;

color clr_plus_file=clrLightSlateGray;

//+------------------------------------------------------------------+

type_ch ust_checkers=NO; // B8? H0H:8 2 >B45;L=>< >:=5 2> 2@5<O @CG=>9 CAB0=>2:8

bool move_White; // true - E>4 15;KE, false - E>4 G5@=KE

bool revers; // =060B0 8;8 =5B :=>?:0 @525@A

bool game; // @568< CAB0=>2:8 (true-83@0, false-@CG=0O CAB0=>2:0 ?>78F88)

bool full_anot; // ?>;=0O 8;8 :@0B:0O 8==>B0F8O E>4>2

int  di; // H03 :;5B>:

int  x0; // =0G0;L=0O :>>@48=0B0 X 4>A:8

int  y0; // =0G0;L=0O :>>@48=0B0 Y 4>A:8

bool all_close=false; // ?@87=0:: A:@KBL/2K25AB8 2A5 ?0=5;8,:=>?:8

bool end_edit=false;

//........................

string pref="ch_";

string name_dir_expert="checkers\\";



string name_file_set =name_dir_expert+"ch";

string pref_file     =name_dir_expert+pref;

string but_beg       =pref+"Ish";

string but_rev       =pref+"Rev";

string but_del_all   =pref+"Del_all";

string but_left      =pref+"left";

string but_right     =pref+"right";

string but_ust       =pref+"ust";

string but_put       =pref+"put";

string but_clr       =pref+"clr";

string but_npos      =pref+"mn";

string but_del_pos   =pref+"md";

string but_yes       =pref+"my";

string but_yes_file  =pref+"fy";

string but_yes_dir   =pref+"dy";

string but_checkers  =pref+"Ch";

string but_app       =pref+"app";

string but_full_anot =pref+"full";

string name_next_move=pref+"NM";

string but_save      =pref+"save";

string but_load      =pref+"load";

string but_del       =pref+"del";

string but_dir_del   =pref+"dir_del";

string but_dir       =pref+"dir";

string but_edit      =pref+"edit";

string but_edit_dir  =pref+"edit_dir";

string but_pred      =pref+"pred";

string but_next      =pref+"next";

string but_cat       =pref+"cat";

string but_up        =pref+"up";

string but_dw        =pref+"dw";

string but_up_dir    =pref+"upd";

string but_dw_dir    =pref+"dwd";

string but_no_plus   =pref+"no+";

//+------------------------------------------------------------------+

class Class_checker // :;0AA H0H:0

{

   private:

      type_ch ch; // H0H:a

      type_move move; // B8? E>40

      int xr; // :>>@48=0B0 x A@C1;5==>9 H0H:8

      int yr; // :>>@48=0B0 y A@C1;5==>9 H0H:8

      bool exist_hew; // ACI5AB2C5B @C1:0 >B MB>9 :;5B:8 8;8 =5B

   public:

      type_ch get(int& x,int& y){x=xr;y=yr;return(ch);} // ?@>G8B0BL :>>@4.A@C1;5==>9 H0H:8 8 5Q B8?

      type_ch get(){return(ch);} // ?@>G8B0BL B8? H0H:8

      type_move get_move(){return(move);} // ?@>G8B0BL B8? E>40

      

      bool get_exist_hew(){return(exist_hew);} // ?@>G8B0BL @C1:C

      void put_exist_hew(bool n){exist_hew=n;} // 70?8A0BL @C1:C

      

      void put(type_ch n){ch=n;} // 70?8A0BL B8? H0H:8

      void put(type_ch n,type_move m,int x,int y){ch=n;move=m;xr=x;yr=y;}// 70?. B8? H0H:8, B8? E>40 8 :>>@4.A@C1;.

      void put(int x,int y){xr=x;yr=y;} // 70?.:>>@48=0BK A@C1;5==>9 H0H:8

      void put(type_move m){move=m;} // 70?8A0BL B8? E>40

      void put(type_move m,int x,int y){move=m;xr=x;yr=y;} // 70?. B8? E>40 8 :>>@4. A@C1;.H0H:8

};

//-----------------------

class Class_koord_checker // :;0AA :>>@48=0BK H0H:8

{

   private:

      int x;

      int y;

      type_ch ch;

   public:

      type_ch get(int& x1,int& y1){x1=x;y1=y;return(ch);} // ?@>G8B0BL :>>@4. 8 B8? H0H:8

      void put(int x1,int y1,type_ch n){x=x1;y=y1;ch=n;} // 70?8A0BL B8? H0H:8 8 5Q :>>@48=0BK

};

//-----------------------

class Class_position // :;0AA ?>78F8O

{

   private:

      Class_checker checkers[8][8]; // <0AA82 H0H5:

      //...............

      int  sum;   // :>;. 2A5E H0H5: =0 4>A:5

      int  sum_w; // :>;.15;KE (white)

      int  sum_b; // :>;.G5@=KE(black)

      int  sum_d; // :>;. 40<>:

      bool move_white_ann; // true-E>4 15;KE, >B>1@0605B ?@8=04;56=>ABL : ?>78F88, 8A?. 2 0==>B0F88

      bool next_move_white; // A;54.E>4. true-E>4 15;KE, 8A?. 4;O >B>1@065=88 =0 ?0=5;8

      int  nom_move;  // =><5@ E>40

      uchar ann[2];   // 0==>B0F8O G0AB8 E>40, =0?@8<5@ "b2" 8;8 "c4"

      uchar action;   // 459AB285: "", "-" 8;8 ":"(=0G0;>,E>4 8;8 @C1:0)AB028BAO ?5@54 E>4><

      void out_inf(string s1="",string s2="",string s3="")

      { // 2K25AB8 B@8 AB@>:8 > A>AB>O=88 ?>78F88

         LabelCreate(0,but_app+"1",0,shift_panel+260+8*di,270,s1,"Arial Black",8,clr_Text);

         LabelCreate(0,but_app+"2",0,shift_panel+260+8*di,285,s2,"Arial Black",8,clr_Text);

         LabelCreate(0,but_app+"3",0,shift_panel+260+8*di,300,s3,"Arial Black",8,clr_Text);

      }

      int sum_white(); // AC<<0 15;KE H0H5:, B0:65 2KG8A;O5BAO AC<<0 2A5E H0H5: 8 AC<<0 2A5E 40<>: 

      int sum_black(); // AC<<0 15;KE H0H5:, B0:65 2KG8A;O5BAO AC<<0 2A5E H0H5: 8 AC<<0 2A5E 40<>: 

      int calc_app(); // ?>AG8B0BL 0??>78F8N

      int calc_inf(); // AD>@<8@>20BL 8=D>@<0F8N

      void out_app(int ap); // 2K25AB8 8=D. >1 0??>78F88

      //...............

      void put_hew_white(int x1,int y1,int x2,int y2,int& n_move,bool set);// 70?8A0BL 2 ?>78F8N 4>?CAB8<K5 E>4K ?>A;5 @C1:8 15;>9  ?@>AB>9 H0H:>9

      void put_hew_black(int x1,int y1,int x2,int y2,int& n_move,bool set);// 70?8A0BL 2 ?>78F8N 4>?CAB8<K5 E>4K ?>A;5 @C1:8 G5@=>9 ?@>AB>9 H0H:>9

      void find_hew_white_king(int i1,int i2,int x,int y,int& n_move,bool set=false);

      void find_hew_black_king(int i1,int i2,int x,int y,int& n_move,bool set=false);

      bool find_hew_king(bool white,int x,int y,int xr,int y);

      void set_let_hew_line(int i1,int i2,int x,int y,bool white);

      //..........................................................

   public:

      Class_position(){nom_move=0;sum=0;sum_w=0;sum_b=0;sum_d=0;} // :>=AB@C:B>@

      bool exist_Hew; // C:07K205B, GB> 5ABL =0 4>A:5 1>9

      bool hew; // @C1:0, 8A?. ?@8 0==>B0F88 E>40

      bool end; // true-?>A;54=OO G0ABL E>40

      void put_ann_uchar(uchar a,uchar c){ann[0]=a;ann[1]=c;}

      void put_ann(int a,int c){ann[0]=(uchar)'a'+(uchar)a;ann[1]=(uchar)('1'+c);}

      string get_ann(){return(CharToString(ann[0])+CharToString(ann[1]));}

      uchar get_ann(int n){return(ann[n]);}

      

      void put_action(uchar n){action=n;}

      string get_action(){return(CharToString(action));}

      uchar get_action_uchar(){return(action);}

      

      void put_move_white_ann(bool n){move_white_ann=n;} // 70?8A0BL 2 ?>78F8N >G5@54=>ABL E>40 (4;O 0==.)

      void put_move_white_ann(){move_white_ann=move_White;} // 70?8A0BL 2 ?>78F8N >G5@54=>ABL E>40 (4;O 0==.)

      bool get_move_white_ann(){return(move_white_ann);} // ?@>G8B0BL 87 ?>78F88 >G5@54=>ABL E>40 (4;O 0==.)

      

      void put_nom_move(int n){nom_move=n;}

      int  get_nom_move(){return(nom_move);}

      

      void put_move_white(bool n){next_move_white=n;} // 70?8A0BL 2 ?>78F8N >G5@54=>ABL E>40

      void put_move_white(){next_move_white=move_White;} // 70?8A0BL 2 ?>78F8N >G5@54=>ABL E>40

      bool get_move_white(){return(next_move_white);} // ?@>G8B0BL 87 ?>78F88 >G5@54=>ABL E>40

      

      void out_inf_pos(){out_app(calc_inf());}// 2K25AB8 8=D>@<0F8N > ?>78F88

      //.............................

      void init_pos(); // >G8AB8BL ?>78F8N

      void begin_pos(); // CAB. =0G0;L=CN ?>78F8N

      

      type_ch get_ch(int x,int y); // ?@>G8B0BL H0H:C 2 ?>78F88

      type_ch put_ch(int x,int y, type_ch ch); // 70?8A0BL H0H:C 2 ?>78F8N

      type_ch del_ch(int x,int y); // C40;8BL H0H:C 87 ?>78F88

      

      bool get_exist_hew(int x,int y){return(checkers[x][y].get_exist_hew());} // ?@>G8B0BL @C1:C

      void put_exist_hew(int x,int y,bool n){checkers[x][y].put_exist_hew(n);} // 70?8A0BL @C1:C

      void init_all_exist_hew(); // AB5@5BL 2A5 2>7<>6=K5 @C1:8

      bool find_all_exist_hew(bool white); // =09B8 8 >B<5B8BL 2A5 2>7<>6=K5 @C1:8

      

      type_move get_move(int x,int y); // ?@>G8B0BL B8? E>40 H0H:8

      void put_move(int x,int y,type_move m){if (x>=0 && x<8 && y>=0 && y<8)checkers[x][y].put(m);} // 70?8A0BL B8? E>40

      void put_move(int x,int y,type_move m,int i,int j){if (x>=0 && x<8 && y>=0 && y<8)checkers[x][y].put(m,i,j);}

      void put_r(int x,int y,int i,int j){if (x>=0 && x<8 && y>=0 && y<8)checkers[x][y].put(i,j);}

      

      void del_all_hew_ch(); // C40;8BL 2A5 >B<5G5==K5 (A@C1;5==K5) H0H:8

      bool get_xy_hew(int i,int j,int& x,int& y); // 70?8A0=K =0 ?CAB>< ?>;5 :>>@4.A@C1;5==>9 H0H:8, ?@8G8B0BL 8E

      //...............

      void set_hew(bool move_white,int x,int y); // >B<5B8BL A@C1;5==CN H0H:C

      void init_all_move();  // C1@0BL 2A5 >B<5B:8 8=48:0F88 E>4>2

      void init_all_let_move();  // C1@0BL 2A5 4>?CAB8<K5 E>4K 2 ?>78F88

      void init_all_beg_move();  // C1@0BL 2A5 =0G0;L=K5 E>4K 2 ?>78F88

      void set_begin_move(int i,int j); // >B<5B8BL 2 ?>78F88 =0G0;L=CN H0H:C

      bool find_set_move_easy(bool mov_white,int x,int y,bool set=true); // =09B8 (8 >B<5B8BL) 4>?CAB8<K5 E>4K ?@>AB>9 H0H:>9

      bool find_set_move_king(bool mov_white,int x,int y,bool set=true); // =09B8 4>?CAB8<K5 E>4K 4;O 40<:8 8 CAB0=>28BL 8E 2 ?>78F88

      bool find_set_hew_easy (bool mov_white,int x,int y,bool set=true); // =09B8 2>7<>6=K5 @C1:8 4;O ?@>AB>9 H0H:8 8 CAB0=>28BL 8E 2 ?>78F88

      bool find_set_hew_king (bool mov_white,int x,int y,bool set=true); // =09B8 2>7<>6=K5 @C1:8 4;O 40<:8 8 CAB0=>28BL 8E 2 ?>78F88

      bool find_all_let(); // =09B8 2A5 >B<5G5==K5 2>7<>6=K5 E>4K

      bool find_all_hew(); // =09B8 2A5 >B<5G5==K5 @C1:8

      void set_let_hew(bool white,int x,int y);

      

      Class_koord_checker  press_ch;

      void out_press(int i,int j,type_ch ch);

};

//---------------------------------

class Class_mas_pos

{

   private:

      Class_position mas_pos[]; // <0AA82 ?>78F89 (>B 0 4> n_pos-1 8;8 4> tek_pos-1)

      int n_pos;     // :>;.?>78F89 2 <0AA825 (0-=5B ?>78F89)

      int tek_pos;   // B5:.?>78F8O (>B 1 4> n_pos)



   public:

      void set_arrow(); // CAB.F25B AB@5;>:

      void init_mas();  // >1=C;8BL <0AA82 ?>78F89

      void put_mas(); // 70?8A0BL 2 <0AA82 >G5@54=CN ?>78F8N

      void put_mas(Class_position& p, int n);

      void get_mas();

      void get_mas(int i,Class_position& p){if (i<ArraySize(mas_pos) && i>=0)p=mas_pos[i];}

      int  get_tek_pos(){return(tek_pos);}

      void put_tek_pos(int n){tek_pos=n;}

      int  get_n_pos(){return(n_pos);}

      void put_n_pos(int n){n_pos=n;}

      void next(); // A?>78F8>=8@>20BLAO =0 A;54CNICN ?>78F8N

      void pred(); // A?>78F8>=8@>20BLAO =0 ?@54K4CICN ?>78F8N

      void out_anot(); // 2K25AB8 0==>B0F8N E>4>2

      void init_out_anot(); // >G8AB8BL 2K2>4 0==>B0F88 E>4>2

      void view_pos();

};

//---------------------------------

class Class_micro_pos

{

   private:

      Class_mas_pos mas_m_pos[sum_micro_pos];

      int n_micro_pos; // :>;. 70?8A0==KE <8:@>?>78F89

      void out_micro_pos(int x,int y,int n);

   public:

      int  get_n_micro(){return(n_micro_pos);}

      void put_n_micro(int n){n_micro_pos=n;}

      

      void init_all_micro_pos(){n_micro_pos=0;ObjectsDeleteAll(0,pref+"m");}

      void get(int i,Class_mas_pos& mas){mas=mas_m_pos[i];}

      void out_all_micro_pos();

      //..............

      void put(int n,Class_mas_pos& mas_p){mas_m_pos[n]=mas_p;} // 70?8AL 2 n-CN OG59:C

      void put() // 70?8AL 2 =C;52CN OG59:C

      {

         Class_position p; // 5A;8 5ABL 2K45;5==K5 :;5B:8 A 2>7<>6=K<8 E>40<8, 70?8AL =5 2>7<>6=0

         mas_position.get_mas(mas_position.get_tek_pos()-1,p);

         if (p.find_all_let())return;

         //...............................

         if (mas_position.get_tek_pos()>0)

         {

            n_micro_pos++;

            if (n_micro_pos>sum_micro_pos)n_micro_pos=sum_micro_pos;

            // A428=CBL <8:@>?>78F88

            for(int i=n_micro_pos-1;i>0;i--)mas_m_pos[i]=mas_m_pos[i-1];

            mas_m_pos[0]=mas_position;// 70?8AL 2 =C;52CN OG59:C

         }

      }

      //..............

      void del(int j) // C40;8BL <8:@>?>78F8N 87 <0AA820 A =><5@>< OG59:8 j

      {

         if (n_micro_pos<=0)return;

         for(int i=j;i<n_micro_pos-1;i++)mas_m_pos[i]=mas_m_pos[i+1];

         n_micro_pos--;

      }

};

//---------------------------------

class Class_board // :;0AA H0H5G=0O 4>A:0

{

   private:

      int y_min_pred,y_max_pred;

      bool calc_krd(); // >?@545;8BL :>>@4.?0=5;8

      void out_ch(int i,int j,type_ch ch); // 2K25AB8 H0H:C =0 ?>;5 i,j



   public:

      bool out_board(bool review=true);

      void out_pos(Class_position& pos); // 2K25AB8 ?>78F8N =0 4>A:C

      void out_question_mark(int i);

      void out_question_mark_dir(int i);

};

//---------------------------------

class Class_catalog

{

   public:

      int  beg_n_catalog;  // =><5@ AB@>:8 D09;0, A :>B>@>9 =0G8=05BAO 2K2>4 =0 M:@0=

      int  beg_n_dir;      // =><5@ AB@>:8 ?0?>:, A :>B>@>9 =0G8=05BAO 2K2>4 =0 M:@0=

      

      bool no_file_plus; // true-=5 2K2>48BL D09;K, 2 :>B>@KE 5ABL A8<2>; "+"

      string  str_cursor; //  A>45@60=85 AB@>:8 :0B0;>30 A :C@A>@><

      string  str_cursor_dir; //  A>45@60=85 AB@>:8 ?0?:8 A :C@A>@><

      

      void put_file_set(); // 70?8A0BL 2 D09; set

      void get_file_set(); // ?@>G8B0BL  D09; set

      void out_catalog_and_dir(string name_file_cursor="",bool cursor_save=false, bool shift=false,bool shift_dir=false);

};

//-------------------------

Class_board          panel;

Class_position       position;

Class_mas_pos        mas_position;

Class_micro_pos      mas_micro_pos;

Class_catalog        catalog;

//+------------------------------------------------------------------+

struct buf_ch // H0H:0 (4;O 70?8A8 2 D09;)

{

   type_ch ch;       // H0H:a

   type_move move;   // B8? E>40

   int xr;           // :>>@48=0B0 x A@C1;5==>9 H0H:8

   int yr;           // :>>@48=0B0 y A@C1;5==>9 H0H:8

   bool exist_hew;   // ACI5AB2C5B @C1:0 >B MB>9 :;5B:8

};

//--------------------

struct buf_pos // ?>78F8O (4;O 70?8A8 2 D09;)

{

   bool move_white_ann;    // true-E>4 15;KE, >B>1@0605B ?@8=04;56=>ABL : ?>78F88, 8A?. 2 0==>B0F88

   bool next_move_white;   // A;54.E>4. true-E>4 15;KE, 8A?. 4;O >B>1@065=88 =0 ?0=5;8

   int  nom_move;          // =><5@ E>40

   uchar ann[2];           // 0==>B0F8O G0AB8 E>40, =0?@8<5@ "b2" 8;8 "c4"

   uchar action;           // 459AB285: "", "-" 8;8 ":"(=0G0;>,E>4 8;8 @C1:0)AB028BAO ?5@54 E>4><

   bool exist_Hew; // C:07K205B, GB> 5ABL =0 4>A:5 1>9

   bool hew; // @C1:0, 8A?. ?@8 0==>B0F88 E>40

   bool end; // true-?>A;54=OO G0ABL E>40

   int x_press;

   int y_press;

   type_ch ch_press;

};

//----------------------

void put_file_pos(int& file_handle,Class_position& pos)

{

   buf_pos buf;



   buf.move_white_ann=pos.get_move_white_ann();

   buf.next_move_white=pos.get_move_white();

   buf.nom_move=pos.get_nom_move();

   buf.ann[0]=pos.get_ann(0);

   buf.ann[1]=pos.get_ann(1);

   buf.action=pos.get_action_uchar();

   buf.exist_Hew=pos.exist_Hew; // C:07K205B, GB> 5ABL =0 4>A:5 1>9

   buf.hew=pos.hew; // @C1:0, 8A?. ?@8 0==>B0F88 E>40

   buf.end=pos.end; // true-?>A;54=OO G0ABL E>40

   buf.ch_press=pos.press_ch.get(buf.x_press,buf.y_press);

   

   FileWriteStruct(file_handle,buf);

   //...................

   buf_ch ch;

   for(int j=0;j<8;j++)

      for(int i=(int)MathMod(j,2);i<8;i+=2)

      {

         ch.ch=pos.get_ch(i,j);

         ch.move=pos.get_move(i,j);

         pos.get_xy_hew(i,j,ch.xr,ch.yr);

         ch.exist_hew=pos.get_exist_hew(i,j);

         

         FileWriteStruct(file_handle,ch);

      }

}

//--------------------

void put_file_mas_pos(int& file_handle,Class_mas_pos& mas_pos)

{

      int sum_pos=mas_pos.get_n_pos();

      FileWriteInteger(file_handle,sum_pos);

      FileWriteInteger(file_handle,mas_pos.get_tek_pos());

      //......................

      Class_position p;

      for(int i=0;i<sum_pos;i++)//70?8H5< 2A5 ?>78F88

      {

         mas_pos.get_mas(i,p);

         put_file_pos(file_handle,p);

      }

}

//----------------------

void get_file_mas_pos(int& file_handle,Class_mas_pos& mas_pos)

{

      int sum_pos=FileReadInteger(file_handle);

      mas_pos.put_n_pos(sum_pos);

      int tek_pos=FileReadInteger(file_handle);

      mas_pos.put_tek_pos(tek_pos);

      //......................

      Class_position p;

      for(int k=0;k<sum_pos;k++)//?@>G8B05< 2A5 ?>78F88

      {

         buf_pos buf;

         FileReadStruct(file_handle,buf);

         

         p.put_move_white_ann(buf.move_white_ann);

         p.put_move_white(buf.next_move_white);

         p.put_nom_move(buf.nom_move);

         p.put_ann_uchar(buf.ann[0],buf.ann[1]);

         p.put_action(buf.action);

         p.exist_Hew=buf.exist_Hew;

         p.hew=buf.hew;

         p.end=buf.end;

         p.press_ch.put(buf.x_press,buf.y_press,buf.ch_press);

         

         buf_ch ch;

         for(int j=0;j<8;j++)

            for(int i=(int)MathMod(j,2);i<8;i+=2)

            {

               FileReadStruct(file_handle,ch);

               

               p.put_ch(i,j,ch.ch);

               p.put_move(i,j,ch.move);

               p.put_move(i,j,ch.move,ch.xr,ch.yr);

               p.put_exist_hew(i,j,ch.exist_hew);

            }

         mas_pos.put_mas(p,k);

      }

}

//----------------------

void put_file(int& file_handle,string name_file="")

{

   if (file_handle==0)

   {

      ResetLastError();

      file_handle=FileOpen(name_dir_expert+name_file,FILE_WRITE|FILE_BIN);

   }

   

   if(file_handle!=INVALID_HANDLE)

   { 

      put_file_mas_pos(file_handle,mas_position); // 70?8H5< B5:CICN ?0@B8N

      //......................

            //70?8H5< <8:@>?>78F88

      int n_micro=mas_micro_pos.get_n_micro();

      FileWriteInteger(file_handle,n_micro);

      

      Class_mas_pos mas_p;

      for(int i=0;i<n_micro;i++)

      {

         mas_micro_pos.get(i,mas_p);

         put_file_mas_pos(file_handle,mas_p);

      }

      //......................

      FileClose(file_handle);

   }

}

//------------------------

void get_file(int& file_handle,string name_file="")

{

   if (file_handle==0)

   {

      string s="",s_dir=StringTrimRight(StringTrimLeft(ObjectGetString(0,but_edit_dir,OBJPROP_TEXT)));

      if (s_dir!="" && s_dir!="...")

         s=s_dir+"\\"+pref+name_file; // 70?8AL 2 C:070==K9 ?>4:0B0;>3

      else

         s=pref+name_file; //70?8AL 2 >A=>2=>9 :0B0;>3

      ResetLastError();

      file_handle=FileOpen(name_dir_expert+s,FILE_READ|FILE_BIN);

   }

   

   if(file_handle!=INVALID_HANDLE)

   {

      get_file_mas_pos(file_handle,mas_position); // ?@>G8B0BL B5:CICN ?0@B8N

      //......................

         // ?@>G8B0BL <8:@>?>78F88

      int n_micro=FileReadInteger(file_handle);

      mas_micro_pos.put_n_micro(n_micro);

      

      Class_mas_pos mas_p;

      for(int i=0;i<n_micro;i++)

      {

         get_file_mas_pos(file_handle,mas_p);

         mas_micro_pos.put(i,mas_p);

      }

      //......................

      FileClose(file_handle);

   }

}

//------------------------

void out_clr_file(string s,color clr)

{

   ObjectSetInteger(0,s,OBJPROP_BGCOLOR,clr);

}

//---------------------

void Class_catalog::put_file_set()

{     // 70?8A0BL 2 D09; set

   ResetLastError();

   int file_handle=FileOpen(name_file_set,FILE_WRITE|FILE_BIN);

   if(file_handle!=INVALID_HANDLE)

   { 

      FileWriteInteger(file_handle,beg_n_catalog);

      FileWriteInteger(file_handle,(int)no_file_plus);

      

      uchar mas_str[100];

      //......................

      int n=StringToCharArray(str_cursor,mas_str);

      FileWriteInteger(file_handle,n-1);      

      for(int i=0;i<n-1;i++)

         FileWriteInteger (file_handle,(int)mas_str[i]);

      //......................

      n=StringToCharArray(str_cursor_dir,mas_str);

      FileWriteInteger(file_handle,n-1);      

      for(int i=0;i<n-1;i++)

         FileWriteInteger (file_handle,(int)mas_str[i]);

      //......................

      put_file(file_handle); // 70?8A0BL B5:CICN ?>78F8N A> 2A5<8 <8:@>?>78F8O<8

      //......................

      FileClose(file_handle);

   }

}

//----------------------------------------

void Class_catalog::get_file_set()

{ // ?@>G8B0BL  D09; set

   ResetLastError();

   int file_handle=FileOpen(name_file_set,FILE_READ|FILE_BIN);

   

   if(file_handle!=INVALID_HANDLE)

   {

      beg_n_catalog=FileReadInteger(file_handle);

      no_file_plus=(bool)FileReadInteger(file_handle);

      

      uchar mas_str[100];

      //......................

      int n=FileReadInteger(file_handle);

      for(int i=0;i<n;i++)

         mas_str[i]=(uchar)FileReadInteger(file_handle);

      str_cursor=CharArrayToString(mas_str,0,n);

      ObjectSetString(0,but_edit,OBJPROP_TEXT,str_cursor);

      //......................

      n=FileReadInteger(file_handle);

      for(int i=0;i<n;i++)

         mas_str[i]=(uchar)FileReadInteger(file_handle);

      str_cursor_dir=CharArrayToString(mas_str,0,n);

      ObjectSetString(0,but_edit_dir,OBJPROP_TEXT,str_cursor_dir);

      //......................

      get_file(file_handle); // ?@>G8B0BL B5:CICN ?>78F8N A> 2A5<8 <8:@>?>78F8O<8



      mas_position.get_mas();

      mas_position.view_pos();

      

      mas_micro_pos.out_all_micro_pos();

      //......................

      FileClose(file_handle);

   }

}

//-----------------------------

void Class_catalog::out_catalog_and_dir(string name_file_cursor="",bool cursor_save=false,bool shift=false,bool shift_dir=false)

{

   if (cursor_save)

      str_cursor=ObjectGetString(0,but_edit,OBJPROP_TEXT);

   else

      if (name_file_cursor != "")

      {

         str_cursor=name_file_cursor;

         ObjectSetString(0,but_edit,OBJPROP_TEXT,str_cursor);

      }

      else

         if (!shift && !shift_dir)get_file_set();



   if (no_file_plus)

      ObjectSetString(0,but_no_plus,OBJPROP_TEXT,"No+");

   else

      ObjectSetString(0,but_no_plus,OBJPROP_TEXT,"All");

   //..................

   string mas_cat[][2]; // <0AA82 :0B0;>30

   int n=0; // B5:CI89 =><5@ AB@>:8 2 :0B0;>35

   int n_str_cursor=-1;

   

   string mas_dir[][2]; // <0AA82 ?0?>:

   ArrayResize(mas_dir,1,10);

   mas_dir[0][0]="...";

   mas_dir[0][1]="";

   int n_dir=1; // B5:CI89 =><5@ AB@>:8 2 A?8A:5 ?0?>:

   int n_str_cursor_dir=-1;

   

   string s=name_dir_expert+"*",file_name;

   string s1=name_dir_expert;

   

   long search_handle=FileFindFirst(s,file_name);

   

   if(search_handle!=INVALID_HANDLE)

   {

         // AD>@<8@>20BL <0AA82 ?0?>:

      string s_dir=StringTrimRight(StringTrimLeft(ObjectGetString(0,but_edit_dir,OBJPROP_TEXT)));

      str_cursor_dir=s_dir;

      do

      {

         bool dir_all_plus=false;

         if (!FileIsExist(s1+file_name)) // =0945= ?0?:0

         {

            if (all_file_plus(s1+file_name)) // 5A;8 2 :0B0;>35 2A5 209;K A + (@5H5==K5)

               if (no_file_plus) // :0B0;>3 =5 2K2>48BL

                  continue;

               else

                  dir_all_plus=true;

            //..............

            n_dir++;

            ArrayResize(mas_dir,n_dir,10);

            string ss=StringSubstr(file_name,0,StringLen(file_name)-1); // C1@0BL ?>A;54=89 A;MH

            ss=StringTrimRight(StringTrimLeft(ss));

            mas_dir[n_dir-1][0]=ss;

            if (dir_all_plus)

               mas_dir[n_dir-1][1]="1";

            else

               mas_dir[n_dir-1][1]="";

         }

      }

      while(FileFindNext(search_handle,file_name));

      FileFindClose(search_handle);

      //........................................  

      for(int i=0;i<n_dir;i++) // =09B8 =><5@ AB@>:8 :C@A>@0 2 <0AA825 ?0?>:

         if (mas_dir[i][0]==str_cursor_dir)n_str_cursor_dir=i;

      //-------------------------------------- 

         // AD>@<8@>20BL <0AA82 D09;>2 2 2K1@0==>9 ?0?:5

      if (s_dir!="" && s_dir!="...")

      {

         s =name_dir_expert+s_dir+"\\*";

         s1=name_dir_expert+s_dir+"\\";

      }

      

      search_handle=FileFindFirst(s,file_name);

      //........................................  

      do

      {

         bool plus_file=false;

         if (FileIsExist(s1+file_name)) // =0945= D09;

            if (StringSubstr(file_name,0,3)==pref)

            {

               string ss=StringSubstr(file_name,3);

               if (StringFind(ss,"+")>0)

                  if (no_file_plus)

                     continue;

                  else

                     plus_file=true;

               n++;

               ArrayResize(mas_cat,n,10);

               mas_cat[n-1][0]=ss;

               if (plus_file)

                  mas_cat[n-1][1]="1";

               else

                  mas_cat[n-1][1]="";

               if (ss==str_cursor)n_str_cursor=n-1;

            }

      }

      while(FileFindNext(search_handle,file_name));

      //...............................

      FileFindClose(search_handle);

      //------------------------------------------

         // 2K25AB8 A?8A>: D09;>2

      LabelCreate(0,but_edit+"n",0,x0-95, 90,(string)n+" files:",  "Arial",8,clr_Text); //:>;.D09;>2

      //...............................

      if (!shift && n_str_cursor>=0)beg_n_catalog=n_str_cursor;

      

      if (n<=max_sum_files)beg_n_catalog=0;

      if (beg_n_catalog>n-max_sum_files)beg_n_catalog=n-max_sum_files;

      if (beg_n_catalog<0)beg_n_catalog=0;

      

      ObjectsDeleteAll(0,but_cat);

      ObjectsDeleteAll(0,but_del);

      

      int k=0;

      for(int i=beg_n_catalog;i<n && i<max_sum_files+beg_n_catalog;i++)

      {

         EditCreate  (but_cat+(string)k,mas_cat[i][0],x0-130,100+20*k,60,20,clr_Text_but,clr_Fon,clrBlue,8,ALIGN_LEFT,true);

         LabelCreate(0,but_del+(string)k,0,x0-60,110+20*k,"X","Arial Black",10,clr_Text); // :@5AB8:

         if (i==n_str_cursor)

            out_clr_file(but_cat+(string)k,clr_Fon_But);

         else

            if (mas_cat[i][1]!="")

               out_clr_file(but_cat+(string)k,clr_plus_file);

         k++;

      }

      //...............................

      if (beg_n_catalog>0)

      {

         LabelCreate(0,but_up,0,x0-35,90,")","wingdings",13,clr_Fon_But1); // AB@5;:0 225@E

         LabelCreate(0,but_up+"n",0,x0-35,110,(string)(beg_n_catalog+1),"Arial",8,clr_Text); //:>;.D09;>2

      }

      else

      {

         ObjectDelete(but_up);

         ObjectDelete(but_up+"n");

      }

      if (n>beg_n_catalog+max_sum_files)

      {

         LabelCreate(0,but_dw,    0,x0-35,110+20*max_sum_files,"*","wingdings",13,clr_Fon_But1); // AB@5;:0 2=87

         LabelCreate(0,but_dw+"n",0,x0-35,90+20*max_sum_files,(string)(beg_n_catalog+max_sum_files),"Arial",8,clr_Text); //:>;.D09;>2

      }

      else

      {

         ObjectDelete(but_dw);

         ObjectDelete(but_dw+"n");

      }

      //---------------------------------------

         // 2K25AB8 A?8A>: ?0?>:

      LabelCreate(0,but_edit_dir+"n",0,x0-168,100,(string)(n_dir-1)+" dir:","Arial",8,clr_Text); //:>;.?0?>:

      //.................................

      if (n_dir<=max_sum_dir)beg_n_dir=0;

      if (beg_n_dir>n_dir-max_sum_dir)beg_n_dir=n_dir-max_sum_dir;

      if (beg_n_dir<0)beg_n_dir=0;

      

      ObjectsDeleteAll(0,but_dir);

      ObjectsDeleteAll(0,but_dir_del);

      

      k=0;

      for(int i=beg_n_dir;i<n_dir && i<max_sum_dir+beg_n_dir;i++)

      {

         EditCreate(but_dir+(string)k,mas_dir[i][0],x0-185,110+20*k,30,20,clr_Text_but,clr_Fon,clrBlue,8,ALIGN_LEFT,true);

         if (i>0)LabelCreate(0,but_dir_del+(string)k,0,x0-148,120+20*k,"X","Arial Black",8,clr_Text); // :@5AB8:

         if (i==n_str_cursor_dir)

            out_clr_file(but_dir+(string)k,clr_Fon_But);

         else

            if (mas_dir[i][1]!="")

               out_clr_file(but_dir+(string)k,clr_plus_file);

            

         k++;

      }

      //...............................

      if (beg_n_dir>0)

         LabelCreate(0,but_up_dir,0,x0-145,100,")","wingdings",10,clr_Fon_But1); // AB@5;:0 225@E

      else

         ObjectDelete(but_up_dir);



      if (n_dir>beg_n_dir+max_sum_dir)

         LabelCreate(0,but_dw_dir,    0,x0-145,120+20*max_sum_dir,"*","wingdings",10,clr_Fon_But1); // AB@5;:0 2=87

      else

         ObjectDelete(but_dw_dir);

   }

}

//---------------------

bool all_file_plus(string dir_name)

{

   bool out=true;

   string file_name="";

   long handle=FileFindFirst(dir_name+"*",file_name);

   //........................................  

   do

   {

      if (FileIsExist(dir_name+file_name)) // =0945= D09;

         if (StringSubstr(file_name,0,3)==pref)

         {

            string ss=StringSubstr(file_name,3);

            if (StringFind(ss,"+")<0)

            {

               out=false;

               break;

            }

         }

   }

   while(FileFindNext(handle,file_name));

   FileFindClose(handle);

   

   return(out);

}

//---------------------------

int OnInit()

{

   if (UninitializeReason()!=REASON_CHARTCHANGE)

   {

      Comment("");

      ChartSetInteger(0,CHART_SHOW_OBJECT_DESCR,false);

      ChartSetInteger(0,CHART_FOREGROUND,false);

      //...........................

      full_anot=false;

      move_White=true;

      revers=false;

      game=true;

      

      panel.out_board();

      put_button();

      position.init_pos();

      

      catalog.beg_n_catalog=0;

      catalog.no_file_plus=false;

      catalog.str_cursor="";

      catalog.get_file_set();

      catalog.out_catalog_and_dir("",false,true);

      //...........................

      EventSetMillisecondTimer(1000);

   }

   return(INIT_SUCCEEDED);

}

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

{

   if (UninitializeReason()!=REASON_CHARTCHANGE)

   {

      ObjectsDeleteAll(0,"ch");

      EventKillTimer();

   }

}

//+------------------------------------------------------------------+

void OnTick()

{

   if (!all_close && panel.out_board(false)) // 2K25AB8 ?0=5;L, 5A;8 @07<5@ M:@0=0 87<5=8;AO

   {

      panel.out_pos(position); // 2K25AB8 ?>78F8N

      put_button();

      position.out_inf_pos(); // 2K25AB8 8=D>@<0F8N > ?>78F88

      mas_micro_pos.out_all_micro_pos();

      mas_position.out_anot();

      if (!game)ObjectSet(but_checkers,OBJPROP_XDISTANCE,shift_panel+237+8*di);

   }

}

//+------------------------------------------------------------------+

void OnTimer()

{

   if (!all_close && panel.out_board(false)) // 2K25AB8 ?0=5;L, 5A;8 @07<5@ M:@0=0 87<5=8;AO

   {

      panel.out_pos(position); // 2K25AB8 ?>78F8N

      put_button();

      position.out_inf_pos(); // 2K25AB8 8=D>@<0F8N > ?>78F88

      mas_micro_pos.out_all_micro_pos();

      mas_position.out_anot();

      if (!game)ObjectSet(but_checkers,OBJPROP_XDISTANCE,shift_panel+237+8*di);

   }

}

//+------------------------------------------------------------------+

void out_txt_but_anot()

{

   if (full_anot)

      ObjectSetString (0,but_full_anot,OBJPROP_TEXT,"Full");

   else

      ObjectSetString (0,but_full_anot,OBJPROP_TEXT,"Short");

}

//----------------

void out_clr_but_revers()

{

   if (revers)

      ObjectSetInteger(0,but_rev,OBJPROP_BGCOLOR,clr_Fon_But);

   else

      ObjectSetInteger(0,but_rev,OBJPROP_BGCOLOR,clr_Fon_off);

}

//-------------------

void save_file()

{

   string s="",s1=ObjectGetString(0,but_edit,OBJPROP_TEXT);

   

   string s_dir=StringTrimRight(StringTrimLeft(ObjectGetString(0,but_edit_dir,OBJPROP_TEXT)));

   if (s_dir!="" && s_dir!="...")

      s=s_dir+"\\"+pref+s1; // 70?8AL 2 C:070==K9 ?>4:0B0;>3

   else

      s=pref+s1; //70?8AL 2 >A=>2=>9 :0B0;>3



   int handle=0;

   put_file(handle,s);

   

   if (del_no_plus_save_plus)

      if (StringFind(s1,"+")>0)

      {

         string s2=StringSubstr(s1,0,StringLen(s1)-1);

         if (s_dir!="" && s_dir!="...")

            s2=name_dir_expert+s_dir+"\\"+pref+s2; // C40;5=85 2 C:070==>< ?>4:0B0;>35

         else

            s2=name_dir_expert+pref+s2; //C40;5=85 2 >A=>2=>< :0B0;>35

         if (FileIsExist(s2))FileDelete(s2);

      }

   

   ObjectsDeleteAll(0,but_cat);

   ObjectsDeleteAll(0,but_del);

   ObjectsDeleteAll(0,but_yes_file);

   catalog.out_catalog_and_dir("",true);

   catalog.put_file_set();

}

//-----------------------------

void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam)

{     // ?@>F54C@0 2K7K205BAO 2> 2@5<O :.-;. 459AB28O >?5@0B>@0

   ResetLastError();//--- A1@>A8< 7=0G5=85 >H81:8

   //...............................

   if (id==CHARTEVENT_OBJECT_ENDEDIT)end_edit=true; // :>=5F @540:B8@>20=8O 8<5=8 D09;0

   if (id==CHARTEVENT_KEYDOWN) // =060B0 :;028H0

      if (end_edit && lparam==13)// 1K; :>=5F @540:B8@>20=8O 8 =060B> Enter

      {

         save_file();

         end_edit=false;

         return;

      }

      else

         end_edit=false;

   //...............................

            //--- ?@>25@:0 A>1KB8O =060B8O :=>?:8 <KH8 =0 >1J5:B5

   if(id==CHARTEVENT_OBJECT_CLICK)

   {

      if(StringSubstr(sparam,0,5)==pref+"my") // =============060B> ?>425@645=85 C40;5=8O >4=>9 <8:@>?>78F88

      {

         int i=StrToInteger(StringSubstr(sparam,5,1)); // ?@>G8B0BL 5Q =><5@

         mas_micro_pos.del(i); // C40;8BL i-CN <8:@>?>78F8N

         mas_micro_pos.out_all_micro_pos(); // 2K25AB8 2A5 (>AB02H85AO) <8:@>?>78F88 =0 M:@0=

         catalog.put_file_set();

         return; 

      }

      else // =5 =060B> ?>4B25@645=85 C40;5=8O

      {

         int j=0; // =09B8, 5ABL ;8 7=0: 2>?@>A0 >:>;> :0:>9-=81C4L <8:@>?>78F88?

         for(j=0;j<sum_micro_pos;j++)

            if (ObjectFind(but_yes+(string)j)>=0)break; // 40,=0945=

         if (j<sum_micro_pos) 

         {// 5A;8 =0945= "?",?5@52K25AB8 2A5 <8:@>?>78F88 (C1@0BL 2>?@>A) 8 2K9B8, 5A;8 =5 =0945= 2K?>;=OBL A;54.:><0=4K

            mas_micro_pos.out_all_micro_pos();

            return;

         }

      }

      if(StringSubstr(sparam,0,5)==but_yes_dir) // =============060B> ?>425@645=85 C40;5=8O >4=>9 ?0?:8

      {

         int i=StrToInteger(StringSubstr(sparam,5)); // ?@>G8B0BL =><5@

         color clr=(color)ObjectGetInteger(0,but_dir+(string)i,OBJPROP_BGCOLOR);

         if (clr!=clrRed)

         {

            ObjectSetInteger(0,but_dir+(string)i,OBJPROP_BGCOLOR,clrRed);

            return;

         }

         else

         {

            string s=ObjectGetString(0,but_dir+(string)i,OBJPROP_TEXT);

            s=name_dir_expert+s+"\\";

            FolderClean(s);

            FolderDelete(s);

            

            ObjectsDeleteAll(0,but_yes_dir);

            

            catalog.out_catalog_and_dir();

            catalog.put_file_set();

            return; 

         }

      }

      else // =5 =060B> ?>4B25@645=85 C40;5=8O

      {

         ObjectsDeleteAll(0,but_yes_dir);

         catalog.out_catalog_and_dir("",false,true);

      }

      if(StringSubstr(sparam,0,5)==but_yes_file) // =============060B> ?>425@645=85 C40;5=8O >4=>3> D09;0

      {

         int i=StrToInteger(StringSubstr(sparam,5)); // ?@>G8B0BL =><5@

         string s=ObjectGetString(0,but_cat+(string)i,OBJPROP_TEXT);

         string s_dir=ObjectGetString(0,but_edit_dir,OBJPROP_TEXT);

         if (s_dir!="" && s_dir!="...")

            s=s_dir+"\\"+pref+s; // C40;5=85 2 C:070==>< ?>4:0B0;>35

         else

            s=pref+s; //C40;5=85 2 >A=>2=>< :0B0;>35

         FileDelete(name_dir_expert+s);

         

         ObjectsDeleteAll(0,but_yes_file);

         

         catalog.out_catalog_and_dir();

         catalog.put_file_set();

         return; 

      }

      else // =5 =060B> ?>4B25@645=85 C40;5=8O

      {

         ObjectsDeleteAll(0,but_yes_file);

         catalog.out_catalog_and_dir("",false,true);

      }

      if(sparam==but_no_plus) // ==================060B0 :=>?:0 "C1@0BL D09;K A +"

      {

         catalog.no_file_plus=!catalog.no_file_plus;

//         catalog.out_catalog_and_dir("",false,true);

         catalog.out_catalog_and_dir("",true);

         catalog.put_file_set();

      }

      if(sparam==but_save)    // ==================060B0 :=>?:0 "70?8AL 2 D09;"

      {

         save_file();

         return;

      }

      if(StringSubstr(sparam,0,6)==but_del) // =====================060B "X" 4;O C40;5=8O >4=>3> D09;0

      {

         int i=StrToInteger(StringSubstr(sparam,6));

            // 70<5=8BL :@5AB8: =0 7=0: 2>?@>A0

         ObjectDelete(sparam);

         panel.out_question_mark(i);

         return;

      }

      if(StringSubstr(sparam,0,10)==but_dir_del) // =====================060B "X" 4;O C40;5=8O >4=>9 ?0?:8

      {

         int i=StrToInteger(StringSubstr(sparam,10));

            // 70<5=8BL :@5AB8: =0 7=0: 2>?@>A0

         ObjectDelete(sparam);

         panel.out_question_mark_dir(i);

         return;

      }

      if(StringSubstr(sparam,0,6)==but_cat) // ==================060B0 AB@>:0 "GB5=85 D09;0"

      {

         string s=ObjectGetString(0,sparam,OBJPROP_TEXT);

         catalog.out_catalog_and_dir(s);



         position.init_pos();

         

         int handle=0;

         get_file(handle,s);

         //..................

         mas_position.get_mas(mas_position.get_tek_pos()-1,position);

         mas_position.set_arrow(); //2K25AB8 AB@5;:8

         

         move_White=position.get_move_white(); // ?@>G8B0BL 87 ?>78F88 >G5@54=>ABL E>40

         out_order_move(); // 2K25AB8 >G5@54=>ABL E>40 =0 M:@0=

         

         mas_position.out_anot(); // 2K25AB8 0==>B0F8N

         

         panel.out_pos(position); // 2K25AB8 ?>78F8N =0 4>A:C

         position.out_inf_pos(); // 2K25AB8 8=D>@<0F8N > ?>78F88

         mas_micro_pos.out_all_micro_pos(); // 2K25AB8 <8:@>?>78F88

         catalog.put_file_set();

         return;

      }

      if(StringSubstr(sparam,0,6)==but_dir) // ==================060B0 AB@>:0 "GB5=85 ?0?:8"

      {

         string s=ObjectGetString(0,sparam,OBJPROP_TEXT);

         ObjectSetString(0,but_edit_dir,OBJPROP_TEXT,s);

         

         catalog.out_catalog_and_dir("",false,true);

         catalog.put_file_set();

      }

      if(sparam==but_beg) // ==================060B0 :=>?:0 "=0G0;L=0O ?>78F8O"

      {

         position.begin_pos(); // AD>@<8@>20BL =0G0;L=CN ?>78F8N

         catalog.put_file_set();

         return;

      }

      if(sparam==but_del_all) // ==================060B0 :=>?:0 Clean (AB5@5BL ?>;5)

      {

         position.init_pos(); // >G8AB8BL ?>78F8N

         catalog.put_file_set();

         return;

      }

      if(sparam==but_left)  // =====================AB@5;:0 2;52>

      {

         mas_position.pred();  // A?>78F8>=8@>20BLAO =0 ?@54K4CICN ?>78F8N

         catalog.put_file_set();

         return;

      }

      if(sparam==but_right) // =======================AB@5;:0 2?@02>

      {

         mas_position.next(); // A?>78F8>=8@>20BLAO =0 A;54CNICN ?>78F8N

         catalog.put_file_set();

         return;

      }

      if(sparam==but_ust) // ==========================060B0 :=>?:0 game/set

      {

         game=!game;

         if (game) // @568< "3@0"

         {

            ObjectSetString (0,but_ust,OBJPROP_TEXT,"Game");

            ObjectSetInteger(0,but_ust,OBJPROP_BGCOLOR,clr_Fon_But);

            

            ObjectDelete(0,but_checkers); // C40;8BL >B45;L=>5 ?>;5

            ObjectDelete(0,but_checkers+"t"); // C40;8BL H0H:C 87 4>?.?>;O

            out_next_move(); // AD>@<8@>20BL =04?8AL >G5@54=>AB8 E>40

            

            position.hew=false;

            move_White=true; // CAB. >G5@54=>ABL E>40

            out_order_move(); // 2K25AB8 >G5@54=>ABL E>40 =0 M:@0=

            

            position.init_all_move(); // C1@0BL 8=48:0F8N E>4>2

            position.init_all_exist_hew(); // AB5@5BL 2A5 2>7<>6=K5 @C1:8

            position.exist_Hew=position.find_all_exist_hew(move_White); // =09B8 8 70?8A0BL 2A5 2>7<>6=K5 @C1:8

            

            position.put_move_white(); // 70?8A0BL 2 ?>78F8N >G5@54=>ABL E>40

            position.put_move_white_ann(); // 70?8A0BL 2 ?>78F8N >G5@54=>ABL E>40 (4;O 0==.)

            position.put_nom_move(0);

            

            mas_position.init_out_anot(); //>G8AB8BL 0==>B0F8N 

            mas_position.put_mas(); // 70?8A0BL 2 <0AA82 >G5@54=CN ?>78F8N

            

            panel.out_pos(position); // 2K25AB8 ?>78F8N =0 4>A:C

            position.out_inf_pos(); // 2K25AB8 8=D>@<0F8N > ?>78F88

            //............................

            mas_micro_pos.put(); // 70?8A0BL B5:CICN ?>78F8N 2 <8:@>?>78F8N

            mas_micro_pos.out_all_micro_pos(); // 2K25AB8 <8:@>?>78F88

            catalog.put_file_set();

         }

         else // @568< "#AB0=>2:0"

         {

            ObjectDelete(name_next_move);

            ObjectSetString (0,but_ust,OBJPROP_TEXT,"Set");

            ObjectSetInteger(0,but_ust,OBJPROP_BGCOLOR,clrRed);

            

            if (clean_all_in_set)

            {

               position.init_pos(); // >G8AB8BL ?>78F8N

               mas_micro_pos.init_all_micro_pos();

            }

            

            position.out_inf_pos(); // 2K25AB8 8=D>@<0F8N > ?>78F88

            ButtonCreate_ch(but_checkers,shift_panel+237+8*di,230,50,50,clr_Osn); // 2K25AB8 4>?>;=8B5;L=>5 ?>;5 4;O CAB. H0H:8

            ust_checkers=NO;

            out_ust_ch_cicle(ust_checkers); // 2K25AB8 15;CN H0H:C 2 4>?.?>;5

         }

         return;

      }

      if(!game && sparam==but_checkers) // =================060B> 4>?.?>;5 2 @568<5 CAB0=>2:0 ?>78F88 (Set)

      {

         out_ust_ch_cicle(ust_checkers); // 2K25AB8 A;54CNICN ?> F8:;C H0H:C 2 4>?.?>;5

         return;

      }

      if(sparam==but_full_anot) // =======================060B0 :=>?:0 ?>;=>9/:@0B:>9 0=>B0F88

      {

         full_anot=!full_anot;

         out_txt_but_anot();

         mas_position.out_anot(); // 2K25AB8 0==>B0F8N

         catalog.put_file_set();

         return;

      }

      if(0 && sparam==name_next_move) // ==========================060B0 :=>?:0 "E>4 15;KE/G5@=KE"

      {

         move_White=!move_White; // A<5=8BL >G5@54=>ABL E>40

         out_order_move(); // 2K25AB8 >G5@54=>ABL E>40 =0 M:@0=

         

         position.init_all_move();  // C1@0BL 8=48:0F8N E>4>2 =0 ?>;5

         position.init_all_exist_hew(); // AB5@5BL 2A5 2>7<>6=K5 @C1:8

         position.exist_Hew=position.find_all_exist_hew(move_White); // =09B8  8 70?8A0BL 2A5 2>7<>6=K5 @C1:8

         

         panel.out_pos(position); // 2K25AB8 ?>78F8N =0 4>A:C

         position.out_inf_pos(); // 2K25AB8 8=D>@<0F8N > ?>78F88

      }

      if(sparam==but_rev) // =========================060B0 :=>?:0 @525@A

      {

         revers=!revers;

         out_clr_but_revers();

            

         panel.out_board(); // 2K25AB8 ?0=5;L

         panel.out_pos(position); // 2K25AB8 ?>78F8N

         mas_micro_pos.out_all_micro_pos(); // 2K25AB8 A?8A>: <8:@>?>78F89

         catalog.put_file_set();

         return;

      }

      if(StringSubstr(sparam,0,4)==pref+"r")  // =====================060B0 :;5B:0 =0 ?>;5

      {     // >?@545;8BL 5Q :>>@48=0BK

         int i=StrToInteger(StringSubstr(sparam,4,1));

         int j=StrToInteger(StringSubstr(sparam,5,1));

         if (game) // @568< 83@K

         {

            type_ch ch=position.get_ch(i,j); // >?@545;8BL B8? =060B>9 H0H:8

            if (ch==NO) // =060B0 ?CAB0O :;5B:0

            {

               if (position.get_move(i,j)==let) // ?@>25@8BL, =060B0O ?CAB0O :;5B:0 ?@8=04;568B @07@5H5==K< E>40<?

               {

                  int x,y;

                  type_ch ch1=position.press_ch.get(x,y); // >?@.B8? 4> MB>3> =060B>9 H0H:8 8 5Q :>>@4. =0 ?>;5

                  position.put_ch(x,y,NO); // C40;8BL =060BCN H0H:C, => >AB028BL :;5B:C ?><5G5==>9, :0: =060BCN

                  position.put_ch(i,j,ch1); // CAB0=>28BL MBC H0H:C =0 ?CAB>5 ?>;5

                  ch1=position.get_ch(i,j); // ?@>G8B0BL B8? 2=>2L CAB0=>2;5==>9 H0H:8,0 24@C3 >=0 ?@52@0B8;0AL 2 40<:C

                  if (position.get_xy_hew(i,j,x,y)) // 5A;8 1K;0 @C1:0, ?@>G8B0BL :>>@4.A@C1;. H0H:8

                  {

                     position.hew=true;

                     position.set_hew(move_White,x,y); // >B<5B8BL A@C1;5==CN H0H:C

                     if (position.find_set_hew_easy(move_White,i,j,false)) // 5ABL ;8 @C1:0 ?@>AB>9 H0H:>9 ?

                     {

                        position.init_all_let_move(); // C40;8BL 8=48:0F8N 4>?CAB8<KE E>4>2

                        position.find_set_hew_easy(move_White,i,j); // CAB.4>?CAB8<K5 E>4K @C1:8 ?@>AB>9 H0H:>9

                        position.set_begin_move(i,j); // 70?8A0BL =0G0;> E>40

                        position.press_ch.put(i,j,ch1); // A>E@0=8BL :>>@4.=060B>9 H0H:8

                        position.put_move_white(); // 70?8A0BL 2 ?>78F8N >G5@54=>ABL E>40

                        position.put_move_white_ann(); // 70?8A0BL 2 ?>78F8N >G5@54=>ABL E>40

                        

                        position.put_ann(i,j);

                        position.put_action(':');

                        

                        mas_position.put_mas(); // 70?8A0BL 2 <0AA82 >G5@54=CN ?>78F8N

                        mas_position.out_anot(); // 2K25AB8 0==>B0F8N

                        panel.out_pos(position); // 2K25AB8 ?>78F8N

                        catalog.put_file_set();

                        return;

                     }

                     else

                        if (position.find_set_hew_king(move_White,i,j,false)) // 5A;8 5ABL 40;LH5 @C1:0 40<:>9?

                        {

                           position.init_all_let_move(); // C40;8BL 8=48:0F8N 4>?CAB8<KE E>4>2

                           position.find_set_hew_king(move_White,i,j);

                           position.set_let_hew(move_White,i,j); // 2K45;8BL E>4K, 345 5ABL 40;L=59H0O @C1:0

                           position.set_begin_move(i,j); // 70?8A0BL =0G0;> E>40

                           position.press_ch.put(i,j,ch1); // A>E@0=8BL :>>@4.=060B>9 H0H:8

                           position.put_move_white(); // 70?8A0BL 2 ?>78F8N >G5@54=>ABL E>40

                           position.put_move_white_ann(); // 70?8A0BL 2 ?>78F8N >G5@54=>ABL E>40

                           

                           position.put_ann(i,j);

                           position.put_action(':');



                           mas_position.put_mas(); // 70?8A0BL 2 <0AA82 >G5@54=CN ?>78F8N

                           mas_position.out_anot(); // 2K25AB8 0==>B0F8N

                           panel.out_pos(position); // 2K25AB8 ?>78F8N

                           catalog.put_file_set();

                           return;

                        }

                  }

                  position.del_all_hew_ch(); // C40;8BL 2A5 >B<5G5==K5 (A@C1;5==K5) H0H:8

                  

                  position.init_all_let_move(); // C1@0BL 8=48:0F8N 4>?.E>4>2

                  position.init_all_beg_move(); // C1@0BL 8=48:0F8N =0G.E>4>2

                  

                  position.put_move_white_ann(); // 70?8A0BL 2 ?>78F8N >G5@54=>ABL E>40

                  move_White=!move_White;   // ?><5=OBL >G5@54=>ABL E>40

                  out_order_move(); // 2K25AB8 >G5@54=>ABL E>40 =0 M:@0=

                  

                  position.init_all_exist_hew(); // AB5@5BL 2A5 2>7<>6=K5 @C1:8

                  position.exist_Hew=position.find_all_exist_hew(move_White); // =09B8  8 70?8A0BL 2A5 2>7<>6=K5 @C1:8

                  

                  position.put_move_white(); // 70?8A0BL 2 ?>78F8N >G5@54=>ABL E>40

                  position.put_ann(i,j);

                  if (position.hew)

                     position.put_action(':');

                  else

                     position.put_action('-');

                  position.hew=false;

                  position.end=true;

                  mas_position.put_mas(); // 70?8A0BL 2 <0AA82 >G5@54=CN ?>78F8N

                  panel.out_pos(position); // 2K25AB8 ?>78F8N =0 M:@0=

                  

                  position.out_inf_pos(); // 2K25AB8 8=D. > ?>78F88

                  mas_position.out_anot(); // 2K25AB8 0==>B0F8N

               }

            }

            else // =060B0 :;5B:0 A H0H:>9

               if (!position.hew && ((move_White && ch>1) || (!move_White && ch<-1))) // F25B H0H:8 A>2?0405B A F25B>< >G5@54=>AB8 E>40? 8 =5B @C1:8

                  if (!position.find_all_let()) // =5B =8 >4=>3> >B<5G5==>3> 2>7<>6=>3> E>40

                  {

                     position.init_all_move(); // C1@0BL 8=48:0F8N E>4>2

                     if (position.find_set_hew_king(move_White,i,j))// 5ABL @C1:0 40<:>9?

                     {

                        position.set_let_hew(move_White,i,j); // 2K45;8BL E>4K, 345 5ABL 40;L=59H0O @C1:0

                        position.out_press(i,j,ch);

                     }

                     else

                     if (position.find_set_hew_easy(move_White,i,j)) // 5ABL @C1:0 ?@>AB>9?

                     {

                        position.out_press(i,j,ch);

                     }

                     else

                        if (!position.find_all_hew()) // =5B =8 >4=>9 >B<5G5==>9 @C1:8

                           if (position.find_set_move_king(move_White,i,j)) // 5ABL E>4 40<:>9?

                              position.out_press(i,j,ch);

                           else

                              if (position.find_set_move_easy(move_White,i,j)) // 5ABL E>4 ?@>AB>9?

                                 position.out_press(i,j,ch);

                     }

         }

         else // @568< CAB0=>2:8 H0H5:

            if (MathMod(i+j,2)==0) // =060B0 B5<=0O :;5B:0 ?>;O ?

            {

               if (position.get_ch(i,j)==NO) // =060B> ?CAB>5 ?>;5 ?

                  position.put_ch(i,j,ust_checkers); // CAB0=>28BL H0H:C =0 4>A:C 87 4>?.?>;O

               else // =060B> ?>;5 A H0H:>9

                  position.put_ch(i,j,NO); // >G8A8BL ?>;5 =0 4>A:5

               panel.out_pos(position); // 2K25AB8 ?>78F8N 

            }

         catalog.put_file_set();

         return;

      }

      if(game && sparam==but_put) // =================060B0 :=>?:0 70?8A0BL B5:CICN ?>78F8N 2 <0AA82 <8:@>?>78F89

      {

         mas_micro_pos.put();

         mas_micro_pos.out_all_micro_pos();

         catalog.put_file_set();

         return;

      }

      if(sparam==but_clr) // ====================060B0 :=>?:0 C40;5=85 2A5E <8:@>?>78F89

      {

         mas_micro_pos.init_all_micro_pos();

         catalog.put_file_set();

         return;

      }

      if(StringSubstr(sparam,0,5)==pref+"md") // =====================060B> C40;5=85 >4=>9 <8:@>?>78F88

      {

         int i=StrToInteger(StringSubstr(sparam,5,1));

            // 70<55=8BL :@5AB8: =0 7=0: 2>?@>A0

         ObjectDelete(but_del_pos+(string)i);

         LabelCreate(0,but_yes+(string)i,0,shift_panel+410+8*di,45*(i+1)+60,"?","Arial Black",12,clr_Text);

         catalog.put_file_set();

         return;

      }

      if(StringSubstr(sparam,0,4)==pref+"m") // ===================060B0 <8:@>?>78F8O (GB5=85)

      {

         int i=StrToInteger(StringSubstr(sparam,4,1));

         mas_micro_pos.get(i,mas_position);

         mas_position.get_mas(mas_position.get_tek_pos()-1,position);

         

         mas_position.set_arrow(); //2K25AB8 AB@5;:8

         

         move_White=position.get_move_white(); // ?@>G8B0BL 87 ?>78F88 >G5@54=>ABL E>40

         out_order_move(); // 2K25AB8 >G5@54=>ABL E>40 =0 M:@0=

         

         mas_position.out_anot(); // 2K25AB8 0==>B0F8N

         

         panel.out_pos(position); // 2K25AB8 ?>78F8N =0 4>A:C

         position.out_inf_pos(); // 2K25AB8 8=D>@<0F8N > ?>78F88

         catalog.put_file_set();

         return;

      }

      if(sparam==but_up) // ===================060B0 :=>?:0 D09; 225@E

      {

         catalog.beg_n_catalog--;

         if (catalog.beg_n_catalog<0)catalog.beg_n_catalog=0;

         catalog.out_catalog_and_dir("",false,true);

         catalog.put_file_set();

         return;

      }

      if(sparam==but_dw) // ===================060B0 :=>?:0 D09; 2=87

      {

         catalog.beg_n_catalog++;

         catalog.out_catalog_and_dir("",false,true);

         catalog.put_file_set();

         return;

      }

      if(sparam==but_up_dir) // ===================060B0 :=>?:0 ?0?:0 225@E

      {

         catalog.beg_n_dir--;

         if (catalog.beg_n_dir<0)catalog.beg_n_dir=0;

         catalog.out_catalog_and_dir("",false,false,true);

         catalog.put_file_set();

         return;

      }

      if(sparam==but_dw_dir) // ===================060B0 :=>?:0 ?0?:0 2=87

      {

         catalog.beg_n_dir++;

         catalog.out_catalog_and_dir("",false,false,true);

         catalog.put_file_set();

         return;

      }

      if(sparam=="chclose") // ===================060B0 :=>?:0 C1@0BL/CAB0=>28BL ?0=5;L

      {

         all_close=!all_close;

         if (all_close)

            ObjectsDeleteAll(0,pref);

         else

         {

            ObjectsDeleteAll(0,"ch");

            panel.out_board();

            put_button();

            position.init_pos();

            

            catalog.beg_n_catalog=0;

            catalog.no_file_plus=false;

            catalog.str_cursor="";

            catalog.get_file_set();

            catalog.out_catalog_and_dir("",false,true);

         }

         return;

      }

   }

}

//==============================================

void Class_mas_pos::set_arrow()

{

   if (tek_pos>1 && tek_pos<=n_pos)

      ObjectSetInteger(0,but_left,OBJPROP_COLOR,clr_Text);

   else

      ObjectSetInteger(0,but_left,OBJPROP_COLOR,clr_Arrow);

   if (tek_pos>=1 && tek_pos<n_pos)

      ObjectSetInteger(0,but_right,OBJPROP_COLOR,clr_Text);

   else

      ObjectSetInteger(0,but_right,OBJPROP_COLOR,clr_Arrow);

}

//---------------------

void Class_mas_pos::init_mas()

{  // >1=C;8BL <0AA82 ?>78F89

   n_pos=0;

   tek_pos=0;

   ArrayResize(mas_pos,0,10);

   set_arrow();

}

//---------------------

void Class_mas_pos::put_mas()

{ // 70?8A0BL 2 <0AA82 >G5@54=CN ?>78F8N

   tek_pos++;

   n_pos=tek_pos;

   ArrayResize(mas_pos,n_pos,10);

   mas_pos[n_pos-1]=position;

   set_arrow();

}

//---------------------

void Class_mas_pos::put_mas(Class_position& p, int n)

{ // 70?8A0BL 2 <0AA82 ?>78F8N

   if (n>0)n=ArraySize(mas_pos);

   ArrayResize(mas_pos,n+1,10);

   mas_pos[n]=p;

}

//---------------------

void Class_mas_pos::get_mas()

{  // ?@>G8B0BL B5:CICN ?>78F8N

   if (tek_pos>0 && tek_pos<=n_pos)position=mas_pos[tek_pos-1];

   set_arrow();

}

//---------------------

void Class_mas_pos::view_pos()

{

   set_arrow();

         

   move_White=position.get_move_white(); // ?@>G8B0BL 87 ?>78F88 >G5@54=>ABL E>40

   out_order_move(); // 2K25AB8 >G5@54=>ABL E>40 =0 M:@0=

   

   out_anot(); // 2K25AB8 0==>B0F8N

   

   panel.out_pos(position); // 2K25AB8 ?>78F8N =0 4>A:C

   position.out_inf_pos(); // 2K25AB8 8=D>@<0F8N > ?>78F88

}

//------------------

void Class_mas_pos::next()

{ // A?>78F8>=8@>20BLAO =0 A;54CNICN ?>78F8N

   while (n_pos>0 && tek_pos<n_pos)

   {

      tek_pos++;

      get_mas();

      if (!position.find_all_let())break;

   }

   view_pos();

}

//---------------------

void Class_mas_pos::pred()

{ // A?>78F8>=8@>20BLAO =0 ?@54K4CICN ?>78F8N

   while (n_pos>0 && tek_pos>1)

   {

      tek_pos--;

      get_mas();

      if (!position.find_all_let())break;

   }

   view_pos();

}

//===========================================

bool Class_board::calc_krd()

{ // >?@545;8BL :>>@4.?0=5;8

   double max=WindowPriceMax();

   double min=WindowPriceMin();

   

   int x_min,x_max; // =5 8A?>;L7CNBAO

   int y_min,y_max;

   ChartTimePriceToXY(0,0,Time[0],max,x_max,y_max);

   ChartTimePriceToXY(0,0,Time[0],min,x_min,y_min);

   

   bool out=y_min!=y_min_pred || y_max!=y_max_pred;

   y_min_pred=y_min;

   y_max_pred=y_max;

   

   x0=195+shift_panel;

   y0=y_max+10;

   int d=y_min-y0-20;

   di=(int)MathFloor(1.0*d/8.0);

   

   return(out);

}

//-----------------

bool Class_board::out_board(bool review=true)

{ // 2K25AB8 4>A:C A :;5B:0<8 =0 M:@0=

   if (review) // >1O70B5;L=> 2K25AB8 ?0=5;L ?

      calc_krd(); // >?@545;8BL :>>@4. 4;O 2K2>40

   else // =5B

      if (!calc_krd())return(false); // 5A;8 @07<5@K M:@0=0 =5 87<5=8;8AL, 2KE>4 (?5@5@8A>2K20BL 4>A:C =5 =C6=>)

   //...................................

     // 2K25AB8 >A=>2=CN ?0=5;L

   out_Rect(9,9,x0-195,y0-10,8*di+720,clrBlack,"p",clrNONE,2,BORDER_FLAT,CORNER_LEFT_UPPER,STYLE_SOLID,false,0);

     // 2K25AB8 ?>4;>6:C ?>4 4>A:C

   out_Rect(10,9,x0,y0,8*di+2,clr_Fon,"p",clrBlue,2,BORDER_FLAT,CORNER_LEFT_UPPER,STYLE_SOLID,false,0);



   ButtonCreate(but_save,x0-65,35,40,20,"Save",10,clr_Fon_But1,clrBlack,"Arial");

   EditCreate  (but_edit_dir,"...",x0-185,35,30,20,clr_Text_but,clr_Fon,clrBlue,8,ALIGN_LEFT);

   LabelCreate(0,pref+"slesh",0,x0-143,45,"\\","Arial Black",12,clr_Text);

   EditCreate  (but_edit,"name file",x0-130,35,60,20,clr_Text_but,clr_Fon,clrBlue,8,ALIGN_LEFT);

   

   ButtonCreate(but_no_plus,x0-120,60,40,20,"NO+",10,clr_Fon_But1,clrBlack,"Arial");

   

   catalog.out_catalog_and_dir();

   //.....................

   int xi=0,yi=0;

   for(int j=0;j<8;j++) // 2K25AB8 @01>G85 (83@>2K5) :;5B:8

      for(int i=(int)MathMod(j,2);i<8;i+=2)

      {

         if (revers)

         {

            xi=x0+di*(7-i);

            yi=y0+di*j;

         }

         else

         {

            xi=x0+di*i;

            yi=y0-di*(j-7);

         }

         out_Rect(i,j,xi,yi,di+2,clr_Osn,"r");

      }

   //.....................

         // 2K25AB8 F8D@K >:>;> ?0=5;8

   if (revers)

      for(int i=0;i<8;i++)

      { 

         LabelCreate(0,pref+"b"+(string)i,0,x0+di*(7-i)+di/2,y0+di*8+8,CharToString((uchar)('a'+i)),"Arial Black",10,clr_Fon_But);

         LabelCreate(0,pref+"c"+(string)i,0,x0-10,y0+di*i+di/2,(string)(i+1),"Arial Black",10,clr_Fon_But);

      }

   else

      for(int i=0;i<8;i++)

      {

         LabelCreate(0,pref+"b"+(string)i,0,x0+di*i+di/2,y0+di*8+8,CharToString((uchar)('a'+i)),"Arial Black",10,clr_Text);

         LabelCreate(0,pref+"c"+(string)i,0,x0-10,y0+di*i+di/2,(string)(8-i),"Arial Black",10,clr_Text);

      }

   return(true);

}

//---------------------

void Class_board::out_question_mark(int i)

{

   LabelCreate(0,but_yes_file+(string)i,0,x0-60,110+20*i,"?","Arial Black",10,clr_Text); // 2>?@>A

}

//----------------------

void Class_board::out_question_mark_dir(int i)

{

   LabelCreate(0,but_yes_dir+(string)i,0,x0-148,120+20*i,"?","Arial Black",8,clr_Text); // 2>?@>A

//         if (i>0)LabelCreate(0,but_del_dir+(string)i,0,x0-148,120+20*i,"X","Arial Black",8,clr_Text); // :@5AB8:

}

//----------------------

void Class_board::out_pos(Class_position& pos)

{ // 2K25AB8 ?>78F8N =0 M:@0=

   calc_krd();

   for(int j=0;j<8;j++)

      for(int i=(int)MathMod(j,2);i<8;i+=2)

      {

         out_ch(i,j,pos.get_ch(i,j)); // 2K25AB8 H0H:C =0 ?0=5;L

         //.....................................

            // 2K25AB8 @0<:C :;5B:8 2 7028A8<>AB8 >B B8?0 E>40

         string name=pref+StringConcatenate("r",i,j);

         switch(pos.get_move(i,j))

         {

            case beg :  // =0G0;L=K9 E>4

               ObjectSetInteger(0,name,OBJPROP_COLOR,clrRed);

               ObjectSetInteger(0,name,OBJPROP_WIDTH,5);

               break;

            case let : // 4>?CAB8<K9 E>4

               ObjectSetInteger(0,name,OBJPROP_COLOR,clrYellow);

               ObjectSetInteger(0,name,OBJPROP_WIDTH,5);

               break;

            default:

               ObjectSetInteger(0,name,OBJPROP_COLOR,clrBlue);

               if (position.get_exist_hew(i,j))

                  ObjectSetInteger(0,name,OBJPROP_WIDTH,5);

               else

                  ObjectSetInteger(0,name,OBJPROP_WIDTH,2);

               break;

         }  

      }

}

//-----------------------

void Class_board::out_ch(int i,int j,type_ch ch)

{ // 2K25AB8 H0H:C =0 4>A:C

   bool ch_white=true;

   bool damka=false;

   bool rub=false;

   switch(ch)

   {

      case pW  : ch_white=true; damka=false;rub=false;break;

      case dW  : ch_white=true; damka=true; rub=false;break;

      case pB  : ch_white=false;damka=false;rub=false;break;

      case dB  : ch_white=false;damka=true; rub=false;break;

      case pWr : ch_white=true; damka=false;rub=true;break;

      case dWr : ch_white=true; damka=true; rub=true;break;

      case pBr : ch_white=false;damka=false;rub=true;break;

      case dBr : ch_white=false;damka=true; rub=true;break;

   }

   //...........................

   string name=pref+StringConcatenate("s",i,j);

   int x=0,y=0;

   if (ch==NO)

   {

      if (ObjectFind(name)>=0)ObjectDelete(name);

   }

   else

   {

      color clr=clrBlack;

      if (rub)clr=clrDarkSlateGray;

      if (ch_white)

      {

         clr=clrWhite;

         if (rub)clr=clrAqua;

      }

      //...................

      if (revers)

      {

         x=x0+di*(7-i);

         y=y0+di*j;

      }

      else

      {

         x=x0+di*i;

         y=y0+di*(7-j);

      }

      //...................

      if (damka)

         LabelCreate(0,name,0,x+di/2,(int)MathCeil(y+di/2+di*0.03),"m","wingdings",(int)MathCeil(di*0.6),clr,-70);

      else

         LabelCreate(0,name,0,x+di/2,(int)MathCeil(y+di/2+di*0.03),"l","wingdings",(int)MathCeil(di*0.7),clr);

   }

}

//===========================================

   //  >A=>2=0O ?0=5;, ?>4;>6:0 ?>4 4>A:C,:;5B:8 =0 4>A:5, @0<:0 :;5B:8, <8:@>?>78F88

void out_Rect(int i,int j,int x, int y,int width,color clr_fon,string s,

               color            clr=clrBlue,              // F25B ?;>A:>9 3@0=8FK (Flat)

               int              line_width=2,             // B>;I8=0 ?;>A:>9 3@0=8FK

               ENUM_BORDER_TYPE border=BORDER_FLAT,       // B8? 3@0=8FK

               ENUM_BASE_CORNER corner=CORNER_LEFT_UPPER, // C3>; 3@0D8:0 4;O ?@82O7:8

               ENUM_LINE_STYLE  style=STYLE_SOLID,        // AB8;L ?;>A:>9 3@0=8FK

               bool             back=false,               // =0 704=5< ?;0=5

               long             z_order=1,                 // ?@8>@8B5B =0 =060B85 <KHLN

               bool             selection=false,          // 2K45;8BL 4;O ?5@5<5I5=89

               bool             hidden=true               // A:@KB 2 A?8A:5 >1J5:B>2

             )

{

   int height=width;

   string name=pref+StringConcatenate(s,i,j);

   if (ObjectFind(0,name)<0)ObjectCreate(0,name,OBJ_RECTANGLE_LABEL,0,0,0);

   

   //--- CAB0=>28< B8? 3@0=8FK

   ObjectSetInteger(0,name,OBJPROP_BORDER_TYPE,border);

      //--- CAB0=>28< C3>; 3@0D8:0, >B=>A8B5;L=> :>B>@>3> 1C4CB >?@545;OBLAO :>>@48=0BK B>G:8

   ObjectSetInteger(0,name,OBJPROP_CORNER,corner);

      //--- CAB0=>28< F25B ?;>A:>9 @0<:8 (2 @568<5 Flat)

   ObjectSetInteger(0,name,OBJPROP_COLOR,clr);

      //--- CAB0=>28< AB8;L ;8=88 ?;>A:>9 @0<:8

   ObjectSetInteger(0,name,OBJPROP_STYLE,style);

      //--- CAB0=>28< B>;I8=C ?;>A:>9 3@0=8FK

   ObjectSetInteger(0,name,OBJPROP_WIDTH,line_width);

      //--- 2:;NG8< (true) 8;8 >B:;NG8< (false) @568< ?5@5<5I5=8O <5B:8 <KHLN

   ObjectSetInteger(0,name,OBJPROP_SELECTABLE,selection);

   ObjectSetInteger(0,name,OBJPROP_SELECTED,selection);

      //--- A:@>5< (true) 8;8 >B>1@078< (false) 8<O 3@0D8G5A:>3> >1J5:B0 2 A?8A:5 >1J5:B>2

   ObjectSetInteger(0,name,OBJPROP_HIDDEN,hidden);

      //--- CAB0=>28< ?@8>@8B5B =0 ?>;CG5=85 A>1KB8O =060B8O <KH8 =0 3@0D8:5

   ObjectSetInteger(0,name,OBJPROP_ZORDER,z_order);   

      //--- >B>1@078< =0 ?5@54=5< (false) 8;8 704=5< (true) ?;0=5

   ObjectSetInteger(0,name,OBJPROP_BACK,back);

   

   ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);

   ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);

      //--- CAB0=>28< @07<5@K <5B:8

   ObjectSetInteger(0,name,OBJPROP_XSIZE,width);

   ObjectSetInteger(0,name,OBJPROP_YSIZE,height);

      //--- CAB0=>28< F25B D>=0

   ObjectSetInteger(0,name,OBJPROP_BGCOLOR,clr_fon);

}

//-------------------------------

   // F8D@K >:>;> 4>A:8, AB@5;:8, 0=>B0F8O, H0H:8: ?@>AB0O 8;8 40<:0

bool LabelCreate(const long              chart_ID=0,               // ID 3@0D8:0

                 const string            name="Label",             // 8<O <5B:8

                 const int               sub_window=0,             // =><5@ ?>4>:=0

                 const int               x=0,                      // :>>@48=0B0 ?> >A8 X

                 const int               y=0,                      // :>>@48=0B0 ?> >A8 Y

                 const string            text="Label",             // B5:AB

                 const string            font="Arial",             // H@8DB

                 const int               font_size=10,             // @07<5@ H@8DB0

                 const color             clr=clrRed,               // F25B

                 const double            angle=0.0,                // =0:;>= B5:AB0

                 const ENUM_ANCHOR_POINT anchor=ANCHOR_CENTER, // A?>A>1 ?@82O7:8

                 const ENUM_BASE_CORNER  corner=CORNER_LEFT_UPPER, // C3>; 3@0D8:0 4;O ?@82O7:8

                 const bool              back=false,               // =0 704=5< ?;0=5

                 const bool              selection=false,          // 2K45;8BL 4;O ?5@5<5I5=89

                 const bool              hidden=true,              // A:@KB 2 A?8A:5 >1J5:B>2

                 const long              z_order=0)                // ?@8>@8B5B =0 =060B85 <KHLN

  {

//--- A1@>A8< 7=0G5=85 >H81:8

   ResetLastError();

//--- A>74048< B5:AB>2CN <5B:C

   if (ObjectFind(chart_ID,name)<0)ObjectCreate(chart_ID,name,OBJ_LABEL,sub_window,0,0);

//--- CAB0=>28< :>>@48=0BK <5B:8

   ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);

   ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);

//--- CAB0=>28< C3>; 3@0D8:0, >B=>A8B5;L=> :>B>@>3> 1C4CB >?@545;OBLAO :>>@48=0BK B>G:8

   ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner);

//--- CAB0=>28< B5:AB

   ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);

//--- CAB0=>28< H@8DB B5:AB0

   ObjectSetString(chart_ID,name,OBJPROP_FONT,font);

//--- CAB0=>28< @07<5@ H@8DB0

   ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);

//--- CAB0=>28< C3>; =0:;>=0 B5:AB0

   ObjectSetDouble(chart_ID,name,OBJPROP_ANGLE,angle);

//--- CAB0=>28< A?>A>1 ?@82O7:8

   ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor);

//--- CAB0=>28< F25B

   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);

//--- >B>1@078< =0 ?5@54=5< (false) 8;8 704=5< (true) ?;0=5

   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);

//--- 2:;NG8< (true) 8;8 >B:;NG8< (false) @568< ?5@5<5I5=8O <5B:8 <KHLN

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);

//--- A:@>5< (true) 8;8 >B>1@078< (false) 8<O 3@0D8G5A:>3> >1J5:B0 2 A?8A:5 >1J5:B>2

   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);

//--- CAB0=>28< ?@8>@8B5B =0 ?>;CG5=85 A>1KB8O =060B8O <KH8 =0 3@0D8:5

   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);

//--- CA?5H=>5 2K?>;=5=85

   return(true);

  }

//+------------------------------------------------------------------+

   // :=>?:8 C?@02;5=8O

bool ButtonCreate(const string  name="button",      // 8<O :=>?:8

                  const int x=0,                    // :>>@48=0B0 ?> >A8 X

                  const int y=0,                    // :>>@48=0B0 ?> >A8 Y

                  const int width=0,                // H8@8=0 :=>?:8

                  const int height=0,               // 2KA>B0 :=>?:8

                  const string text="",             // B5:AB

                  const int font_size=10,            // @07<5@ H@8DB0

                  const color  back_clr=clrYellow,    // F25B D>=0 

                  const color clr=clrBlack,          // F25B B5:AB0

                  const string  font="Arial Black",     // H@8DB

                  const bool back=false,            // =0 704=5< ?;0=5

                  const long z_order=1,             // ?@8>@8B5B =0 =060B85 <KHLN

                  const bool state=false,           // =060B0/>B60B0                                                  

                  const color border_clr=clrBlue,   // F25B 3@0=8FK  

                  //------------------------------------------------               

                  const bool selection=false,       // 2K45;8BL 4;O ?5@5<5I5=89

                  const bool hidden=false)          // A:@KB 2 A?8A:5 >1J5:B>2

  {

//--- A1@>A8< 7=0G5=85 >H81:8

   ResetLastError();



   if(ObjectFind(name)==-1)

     {

      //--- A>74048< :=>?:C

      ObjectCreate(0,name,OBJ_BUTTON,0,0,0);

      //--- CAB0=>28< C3>; 3@0D8:0, >B=>A8B5;L=> :>B>@>3> 1C4CB >?@545;OBLAO :>>@48=0BK B>G:8

      ObjectSetInteger(0,name,OBJPROP_CORNER,CORNER_LEFT_UPPER);

      //--- A:@>5< (true) 8;8 >B>1@078< (false) 8<O 3@0D8G5A:>3> >1J5:B0 2 A?8A:5 >1J5:B>2

      ObjectSetInteger(0,name,OBJPROP_HIDDEN,hidden);

      //--- CAB0=>28< ?@8>@8B5B =0 ?>;CG5=85 A>1KB8O =060B8O <KH8 =0 3@0D8:5

      ObjectSetInteger(0,name,OBJPROP_ZORDER,z_order);

     }

   //--- CAB0=>28< F25B B5:AB0

   ObjectSetInteger(0,name,OBJPROP_COLOR,clr);

   //--- CAB0=>28< @07<5@ H@8DB0

   ObjectSetInteger(0,name,OBJPROP_FONTSIZE,font_size);

   //--- CAB0=>28< H@8DB B5:AB0

   ObjectSetString(0,name,OBJPROP_FONT,font);

   //--- >B>1@078< =0 ?5@54=5< (false) 8;8 704=5< (true) ?;0=5

   ObjectSetInteger(0,name,OBJPROP_BACK,back);

   //--- CAB0=>28< F25B 3@0=8FK

   ObjectSetInteger(0,name,OBJPROP_BORDER_COLOR,border_clr);

      //--- CAB0=>28< F25B D>=0

   ObjectSetInteger(0,name,OBJPROP_BGCOLOR,back_clr);

   ObjectSetInteger(0,name,OBJPROP_COLOR,clr);

   

   ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);

   ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);

   //--- CAB0=>28< @07<5@ :=>?:8

   ObjectSetInteger(0,name,OBJPROP_XSIZE,width);

   ObjectSetInteger(0,name,OBJPROP_YSIZE,height);

   ObjectSetString(0,name,OBJPROP_TEXT,text);

   ObjectSetInteger(0,name,OBJPROP_STATE,state);

      //--- 2:;NG8< (true) 8;8 >B:;NG8< (false) @568< ?5@5<5I5=8O :=>?:8 <KHLN

   ObjectSetInteger(0,name,OBJPROP_SELECTABLE,selection);

   ObjectSetInteger(0,name,OBJPROP_SELECTED,selection);

//--- CA?5H=>5 2K?>;=5=85

   return(true);

  }

//+------------------------------------------------------------------+

   // 4>?>;=8B5;L=>5 ?>;5 4;O CAB0=>2:8 H0H:8 2 @CG=CN

bool ButtonCreate_ch(const string  name="button",      // 8<O :=>?:8

                  const int x=0,                    // :>>@48=0B0 ?> >A8 X

                  const int y=0,                    // :>>@48=0B0 ?> >A8 Y

                  const int width=0,                // H8@8=0 :=>?:8

                  const int height=0,               // 2KA>B0 :=>?:8

                  const color  back_clr=clrBlack,    // F25B D>=0 

                  const string text="",             // B5:AB

                  const string  font="",     // H@8DB

                  const int font_size=10,            // @07<5@ H@8DB0

                  const color clr=clrBlack,          // F25B B5:AB0

                  const bool state=false,           // =060B0/>B60B0                                                  

                  const color border_clr=clrBlue,   // F25B 3@0=8FK  

                  //------------------------------------------------               

                  const bool selection=false,       // 2K45;8BL 4;O ?5@5<5I5=89

                  const bool back=false,            // =0 704=5< ?;0=5

                  const bool hidden=false,          // A:@KB 2 A?8A:5 >1J5:B>2

                  const long z_order=1)             // ?@8>@8B5B =0 =060B85 <KHLN

  {

//--- A1@>A8< 7=0G5=85 >H81:8

   ResetLastError();



   if(ObjectFind(name)==-1)

     {

      //--- A>74048< :=>?:C

      ObjectCreate(0,name,OBJ_BUTTON,0,0,0);

      //--- CAB0=>28< C3>; 3@0D8:0, >B=>A8B5;L=> :>B>@>3> 1C4CB >?@545;OBLAO :>>@48=0BK B>G:8

      ObjectSetInteger(0,name,OBJPROP_CORNER,CORNER_LEFT_UPPER);

      //--- A:@>5< (true) 8;8 >B>1@078< (false) 8<O 3@0D8G5A:>3> >1J5:B0 2 A?8A:5 >1J5:B>2

      ObjectSetInteger(0,name,OBJPROP_HIDDEN,hidden);

      //--- CAB0=>28< ?@8>@8B5B =0 ?>;CG5=85 A>1KB8O =060B8O <KH8 =0 3@0D8:5

      ObjectSetInteger(0,name,OBJPROP_ZORDER,z_order);

     }

   //--- CAB0=>28< F25B B5:AB0

   ObjectSetInteger(0,name,OBJPROP_COLOR,clr);

   //--- CAB0=>28< @07<5@ H@8DB0

   ObjectSetInteger(0,name,OBJPROP_FONTSIZE,font_size);

   //--- CAB0=>28< H@8DB B5:AB0

   ObjectSetString(0,name,OBJPROP_FONT,font);

   //--- >B>1@078< =0 ?5@54=5< (false) 8;8 704=5< (true) ?;0=5

   ObjectSetInteger(0,name,OBJPROP_BACK,back);

   //--- CAB0=>28< F25B 3@0=8FK

   ObjectSetInteger(0,name,OBJPROP_BORDER_COLOR,border_clr);

      //--- CAB0=>28< F25B D>=0

   ObjectSetInteger(0,name,OBJPROP_BGCOLOR,back_clr);

   ObjectSetInteger(0,name,OBJPROP_COLOR,clr);

   

   ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);

   ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);

   //--- CAB0=>28< @07<5@ :=>?:8

   ObjectSetInteger(0,name,OBJPROP_XSIZE,width);

   ObjectSetInteger(0,name,OBJPROP_YSIZE,height);

   ObjectSetString(0,name,OBJPROP_TEXT,text);

   ObjectSetInteger(0,name,OBJPROP_STATE,state);

      //--- 2:;NG8< (true) 8;8 >B:;NG8< (false) @568< ?5@5<5I5=8O :=>?:8 <KHLN

   ObjectSetInteger(0,name,OBJPROP_SELECTABLE,selection);

   ObjectSetInteger(0,name,OBJPROP_SELECTED,selection);

//--- CA?5H=>5 2K?>;=5=85

   return(true);

  }

//============================================================

bool EditCreate(

                const string           name="Edit",              // 8<O >1J5:B0

                const string           text="Verdana",           // B5:AB               

                const int              x=110,                    // :>>@48=0B0 ?> >A8 X

                const int              y=110,                    // :>>@48=0B0 ?> >A8 Y

                const int              width=90,                 // H8@8=0

                const int              height=12,                // 2KA>B0

                const color            clr=clrBlack,             // F25B B5:AB0              

                const color            back_clr=clrDarkGray,     // F25B D>=0

                const color            border_clr=clrYellow,     // F25B 3@0=8FK

                const int              font_size=7,              // @07<5@ H@8DB0

                const ENUM_ALIGN_MODE  align=ALIGN_CENTER,        // A?>A>1 2K@02=820=8O

                //------------------------------------------------------------------

                const bool             read_only=false,          // 2>7<>6=>ABL @540:B8@>20BL

                const string           font="Verdana",           // H@8DB

                const ENUM_BASE_CORNER corner=CORNER_LEFT_UPPER,// C3>; 3@0D8:0 4;O ?@82O7:8

                const bool             back=false,               // =0 704=5< ?;0=5

                const bool             selection=false,          // 2K45;8BL 4;O ?5@5<5I5=89

                const bool             hidden=false,             // A:@KB 2 A?8A:5 >1J5:B>2

                const long             z_order=0,                // ?@8>@8B5B =0 =060B85 <KHLN

                const long             chart_ID=0,               // ID 3@0D8:0

                const int              sub_window=0              // =><5@ ?>4>:=0

                )

  {

//--- A1@>A8< 7=0G5=85 >H81:8

   ResetLastError();

   if(ObjectFind(name)==-1)

     {

      //--- A>74048< ?>;5 22>40

      ObjectCreate(chart_ID,name,OBJ_EDIT,sub_window,0,0);

      //--- CAB0=>28< @07<5@K >1J5:B0

      ObjectSetInteger(chart_ID,name,OBJPROP_XSIZE,width);

      ObjectSetInteger(chart_ID,name,OBJPROP_YSIZE,height);

      //--- CAB0=>28< B5:AB

      //  ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);

      //--- CAB0=>28< H@8DB B5:AB0

      ObjectSetString(chart_ID,name,OBJPROP_FONT,font);

      //--- CAB0=>28< @07<5@ H@8DB0

      ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);

      //--- CAB0=>28< A?>A>1 2K@02=820=8O B5:AB0 2 >1J5:B5

      ObjectSetInteger(chart_ID,name,OBJPROP_ALIGN,align);

      //--- CAB0=>28< (true) 8;8 >B<5=8< (false) @568< B>;L:> 4;O GB5=8O

      ObjectSetInteger(chart_ID,name,OBJPROP_READONLY,read_only);

      //--- CAB0=>28< C3>; 3@0D8:0, >B=>A8B5;L=> :>B>@>3> 1C4CB >?@545;OBLAO :>>@48=0BK >1J5:B0

      ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner);

      //--- CAB0=>28< F25B B5:AB0

      ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);

      //--- CAB0=>28< F25B D>=0

      ObjectSetInteger(chart_ID,name,OBJPROP_BGCOLOR,back_clr);

      //--- CAB0=>28< F25B 3@0=8FK

      ObjectSetInteger(chart_ID,name,OBJPROP_BORDER_COLOR,border_clr);

      //--- >B>1@078< =0 ?5@54=5< (false) 8;8 704=5< (true) ?;0=5

      ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);

      //--- 2:;NG8< (true) 8;8 >B:;NG8< (false) @568< ?5@5<5I5=8O <5B:8 <KHLN

      ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);

      ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);

      //--- A:@>5< (true) 8;8 >B>1@078< (false) 8<O 3@0D8G5A:>3> >1J5:B0 2 A?8A:5 >1J5:B>2

      ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);

      //--- CAB0=>28< ?@8>@8B5B =0 ?>;CG5=85 A>1KB8O =060B8O <KH8 =0 3@0D8:5

      ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);

     }

   //--- CAB0=>28< :>>@48=0BK >1J5:B0

   ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);

   ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);

   

   ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);

//--- CA?5H=>5 2K?>;=5=85

   return(true);

  }

//=======================================================================

void Class_position::begin_pos()

{  // 70?8A0BL =0G.?>78F8N

   for(int i=0;i<8;i+=2)

   {

      checkers[i][0].put(pW,no,-1,-1);

      checkers[i][2].put(pW,no,-1,-1);

      checkers[i][4].put(NO,no,-1,-1);

      checkers[i][6].put(pB,no,-1,-1);

   }

   for(int i=1;i<8;i+=2)

   {

      checkers[i][1].put(pW,no,-1,-1);

      checkers[i][3].put(NO,no,-1,-1);

      checkers[i][5].put(pB,no,-1,-1);

      checkers[i][7].put(pB,no,-1,-1);

   }

         

   move_White=true; // CAB. >G5@54=>ABL E>40 (E>4 15;KE)

   out_order_move(); // 2K25AB8 >G5@54=>ABL E>40 =0 M:@0=

   

   hew=false; // CAB.=5B @C1:8

   put_move_white(); // 70?8A0BL 2 ?>78F8N >G5@54=>ABL E>40

   put_move_white_ann(); // 70?8A0BL 2 ?>78F8N >G5@54=>ABL E>40 (4;O 0==>B0F88)

   

   init_all_exist_hew(); // AB5@5BL 2A5 2>7<>6=K5 @C1:8

   put_nom_move(0); // 70?8A0BL 2 ?>78F8N: =><5@ E>40 0

   

   mas_position.init_out_anot(); //>G8AB8BL 0==>B0F8N 

   mas_position.init_mas();  // >1=C;8BL <0AA82 ?>78F89

   mas_position.put_mas(); // 70?8A0BL 2 <0AA82 >G5@54=CN ?>78F8N

   

   panel.out_pos(position); // 2K25AB8 ?>78F8N =0 4>A:C

   out_inf_pos(); // 2K25AB8 8=D>@<0F8N > ?>78F88

}

//----------------------------------------

void Class_position::init_pos()

{  // >1=C;8BL ?>78F8N

   for(int j=0;j<8;j++)

      for(int i=(int)MathMod(j,2);i<8;i+=2)

         checkers[i][j].put(NO,no,-1,-1);

         

   hew=false;

   move_White=true; // CAB. >G5@54=>ABL E>40

   put_nom_move(0);

   out_order_move(); // 2K25AB8 >G5@54=>ABL E>40 =0 M:@0=

   

   init_all_exist_hew(); // AB5@5BL 2A5 2>7<>6=K5 @C1:8

   put_nom_move(0);

   

   mas_position.init_out_anot(); //>G8AB8BL 0==>B0F8N 

   mas_position.init_mas();  // >1=C;8BL <0AA82 ?>78F89

   panel.out_pos(position); // 2K25AB8 ?>78F8N =0 4>A:C

   out_inf_pos(); // 2K25AB8 8=D>@<0F8N > ?>78F88

}

//----------------------------------------

bool Class_position::find_all_let()

{   // ?@>25@8BL, 5ABL ;8 >B<5G5==K5 2>7<>6=K5 E>4K

   bool out=false;

   for(int j=0;j<8;j++)

   {

      for(int i=(int)MathMod(j,2);i<8;i+=2)

         if (get_move(i,j)==let)

         {

            out=true;

            break;

         }

      if (out)break;

   }

   return(out);

}

//----------------------------------------

bool Class_position::find_all_hew()

{   // ?@>25@8BL, 5ABL ;8 >B<5G5==K5 @C1:8

   bool out=false;

   for(int j=0;j<8;j++)

   {

      for(int i=(int)MathMod(j,2);i<8;i+=2)

         if (get_exist_hew(i,j))

         {

            out=true;

            break;

         }

      if (out)break;

   }

   return(out);

}

//----------------------------------------

int Class_position::sum_white()

{  // ?>AG8B0BL AC<<C 15;KE H0H5:

   sum_w=0;

   for(int j=0;j<8;j++)

      for(int i=(int)MathMod(j,2);i<8;i+=2)

      {

         type_ch ch=get_ch(i,j);

         if (ch>1)

         {

            if (ch==dW)sum_d++;

            sum_w++;

            sum++;

         }

      }

   return(sum_w);

}

//--------------------

int Class_position::sum_black()

{  // ?>AG8B0BL AC<<C G5@=KE H0H5:

   sum_b=0;

   for(int j=0;j<8;j++)

      for(int i=(int)MathMod(j,2);i<8;i+=2)

      {

         type_ch ch=get_ch(i,j);

         if (ch<-1)

         {

            if (ch==dB)sum_d++;

            sum_b++;

            sum++;

         }

      }

   return(sum_b);

}

//--------------------

int Class_position::calc_app()

{  // ?>AG8B0BL 0??>78F8N

   int out=0;

   sum=0;   // AC<<0 2A5E H0H5:

   sum_d=0; // :>;. 40<>:

   

   sum_w=sum_white(); // :>;.15;KE

   sum_b=sum_black(); //  8 G5@=KE

      

   if (sum>0 && sum_d==0)

      if (sum_w==sum_b)

      {

         for(int j=0;j<8;j+=2)

            for(int i=(int)MathMod(j,2);i<8;i+=2)

                if (get_ch(i,j)!=NO)sum++;

            

         if (sum==0)

            for(int j=1;j<8;j+=2)

               for(int i=(int)MathMod(j,2);i<8;i+=2)

                   if (get_ch(i,j)!=NO)sum++;

         

         if (sum!=0)

            if (MathMod(sum,2)==0)

               out=-1;

            else

               out=1;

      }

      else

         if (sum_w>sum_b)

            out=sum_w-sum_b+1;

         else

            out=sum_w-sum_b-1;

   //...................

   return(out);

}

//--------------------

int Class_position::calc_inf()

{ // 2KG8A;8BL 8=D>@<0F8N ?5@54 2K2>4><

   if (!game)return(Clear_inf); // 2 @568<5 "CAB0=>2:0", C1@0BL 8=D>@<0F8N

   //............................

   int delta_easy=calc_app(); // 2KG8A;8BL @07=8FC ?@>ABKE H0H5:, 5A;8 >=0 @02=0 =C;N, ?>AG8B0BL 0??>78F8N

   //...............................

   if (sum==0)  return(Clear_inf); // H0H5: =5B, C1@0BL 8=D>@<0F8N

   if (sum_w==0)return(Black_victory); // 15;KE =5B, G5@=K5 ?>1548;8

   if (sum_b==0)return(White_victory); // G5@=KE =5B, 15;K5 ?>1548;8

   //........................

        // ?@>25@8BL, 5ABL ;8 E>4K C E>4OI53>

   bool out=false;

   for(int j=0;j<8;j++)

   {

      for(int i=(int)MathMod(j,2);i<8;i+=2)

      {

         if (find_set_move_easy(move_White,i,j,false)){out=true;break;}else // =09B8 4>?CAB8<K5 E>4K ?@>AB>9 H0H:>9

         if (find_set_move_king(move_White,i,j,false)){out=true;break;}else // =09B8 4>?CAB8<K5 E>4K 4;O 40<:8

         if (find_set_hew_easy (move_White,i,j,false)){out=true;break;}else // =09B8 2>7<>6=K5 @C1:8 4;O ?@>AB>9 H0H:8

         if (find_set_hew_king (move_White,i,j,false)){out=true;break;}     // =09B8 2>7<>6=K5 @C1:8 4;O 40<:8 

      }

      if (out)break;

   }

   if (!out) // 5A;8 C E>4OI53> =5B E>4>2

   {

      if (move_White)return(Black_victory); // B>, 5A;8 E>4 15;KE, G5@=K5 ?>1548;8

      return(White_victory); // 8;8 15;K5 ?>1548;8

   }

   //........................

   // 5A;8 C E>4OI53> 5ABL E>4K

   if(sum_d==0)return(delta_easy); // 5A;8 =5B 40<>:, 2K25AB8 0??>78F8N

   

   return(Clear_inf); // C1@0BL 8=D>@<0F8N

}

//--------------------------

void Class_position::out_app(int ap)

{ // 2K25AB8 8=D>@<0F8N

   switch(ap)

   {

      case  White_victory : if (language_inf==rus)out_inf("5;K5" ,"2K83@0;8!");else out_inf("White" ,"won!");break;

      case  Black_victory : if (language_inf==rus)out_inf("'5@=K5","2K83@0;8!");else out_inf("Black" ,"won!");break;

      case  Clear_inf     : if (language_inf==rus)out_inf();break;

      case    1 : if (language_inf==rus)out_inf("??>78F8O","2 ?>;L7C",   "E>4OI53>");else out_inf("Opposition","in favor","of the Walker");break;

      case   -1 : if (language_inf==rus)out_inf("??>78F8O"," 2 ?>;L7C","E>4OI53>");else out_inf("Opposition","is not in favor","of the Walker");break; 

      default   : if (ap>1)

                     if (language_inf==rus)out_inf("5;KE","1>;LH5","=0 "+(string)(ap-1));else out_inf("White","more","than "+(string)(ap-1));

                  else

                     if (language_inf==rus)out_inf("'5@=KE","1>;LH5","=0 "+(string)(-ap-1));else out_inf("Black","more","than "+(string)(-ap-1));

                  break;

   }

}

//--------------------

void Class_position::init_all_move()

{ // C1@0BL ;N1CN 8=48:0F8N E>4>2

   for(int j=0;j<8;j++)

      for(int i=(int)MathMod(j,2);i<8;i+=2)

      {

         put_move(i,j,off); // 70?8A0BL B8? E>40

         end=false;

      }

}

//-------------------------------

void Class_position::init_all_let_move()

{ // C1@0BL 2A5 4>?CAB8<K5 E>4K 2 ?>78F88

   for(int j=0;j<8;j++)

      for(int i=(int)MathMod(j,2);i<8;i+=2)

         if (get_move(i,j)==let)put_move(i,j,off,-1,-1); // 70?8A0BL B8? E>40

}

//-------------------------------

void Class_position::init_all_beg_move()

{ // C1@0BL 2A5 =0G0;L=K5 E>4K 2 ?>78F88

   for(int j=0;j<8;j++)

      for(int i=(int)MathMod(j,2);i<8;i+=2)

         if (get_move(i,j)==beg)put_move(i,j,off,-1,-1); // 70?8A0BL B8? E>40

}

//-------------------------------

bool Class_position::find_all_exist_hew(bool white)

{ // =09B8  8 70?8A0BL 2A5 2>7<>6=K5 @C1:8

   bool out=false;

   for(int j=0;j<8;j++)

      for(int i=(int)MathMod(j,2);i<8;i+=2)

         if (find_set_hew_easy (white,i,j,false)) // =09B8 2>7<>6=K5 @C1:8 4;O ?@>AB>9 H0H:8

         {

            put_exist_hew(i,j,true);

            out=true;

         }

         else

            if (find_set_hew_king (white,i,j,false)) // =09B8 2>7<>6=K5 @C1:8 4;O 40<:8

            {

               put_exist_hew(i,j,true); 

               out=true;

            }

   return(out);

}

//--------------------

void Class_position::init_all_exist_hew()

{  // C40;8BL 2A5 @C1:8 (>B<5B:8)

   for(int j=0;j<8;j++)

      for(int i=(int)MathMod(j,2);i<8;i+=2)

      {

         put_exist_hew(i,j,false);

         position.put_r(i,j,-1,-1);

      }

}

//--------------------------------

void Class_position::del_all_hew_ch()

{  // C40;8BL >B<5G5==K5 (A@C1;5==K5) H0H:8

   for(int j=0;j<8;j++)

      for(int i=(int)MathMod(j,2);i<8;i+=2)

         if ((int)MathAbs((int)get_ch(i,j))>3)del_ch(i,j);

}

//--------------------------------

void Class_position::set_begin_move(int i,int j)

{ // 70?8A0BL =0G0;> E>40

   position.put_move(i,j,beg); 

}

//----------------------

bool Class_position::find_set_move_easy(bool mov_white,int x,int y,bool set=true)

{  // =09B8 4>?CAB8<K5 E>4K 4;O ?@>AB>9 H0H:8 8 CAB0=>28BL 8E 2 ?>78F88

   int n_move=0;

 

   type_ch ch=position.get_ch(x,y);

   if (mov_white) // E>4 15;KE

   {

      if (ch==pW) // ?@>AB0O 15;0O

      {

         if (get_ch(x-1,y+1)==NO){if (set)put_move(x-1,y+1,let);n_move++;} // A;520 ?CAB>

         if (get_ch(x+1,y+1)==NO){if (set)put_move(x+1,y+1,let);n_move++;} // A?@020 ?CAB>

      }

   }

   else // E>4 G5@=KE

      if (ch==pB) // ?@>AB0O G5@=0O

      {

         if (get_ch(x-1,y-1)==NO){if (set)put_move(x-1,y-1,let);n_move++;} // A?@020 ?CAB>

         if (get_ch(x+1,y-1)==NO){if (set)put_move(x+1,y-1,let);n_move++;} // A;520 ?CAB>

      }

   return(n_move>0);

}

//----------------------

bool Class_position::find_set_move_king(bool mov_white,int x,int y,bool set=true)

{  // =09B8 4>?CAB8<K5 E>4K 4;O 40<:8 8 CAB0=>28BL 8E 2 ?>78F88

   int n_move=0;

   

   type_ch ch=get_ch(x,y);

   if ((mov_white && ch==dW) || (!mov_white && ch==dB)) // 40<:0 15;0O 8;8 G5@=0O A>2?0405B A >G5@545@ABLN E>40

   {

      for(int i=1;i<8;i++)

         if (get_ch(x+i,y+i)==NO){if (set)put_move(x+i,y+i,let);n_move++;}else break; // A?@020 225@E

      for(int i=1;i<8;i++)

         if (get_ch(x-i,y+i)==NO){if (set)put_move(x-i,y+i,let);n_move++;}else break; // A;520 225@E

      for(int i=1;i<8;i++)

         if (get_ch(x+i,y-i)==NO){if (set)put_move(x+i,y-i,let);n_move++;}else break; // A?@020 2=87

      for(int i=1;i<8;i++)

         if (get_ch(x-i,y-i)==NO){if (set)put_move(x-i,y-i,let);n_move++;}else break; // A;520 2=87

   }

   return(n_move>0);

}

//----------------------

bool Class_position::find_set_hew_easy(bool mov_white,int x,int y,bool set=true)

{  // =09B8 2>7<>6=K5 @C1:8 4;O ?@>AB>9 H0H:8 8 CAB0=>28BL 8E 2 ?>78F88

   int n_move=0;

   

   type_ch ch=get_ch(x,y);

   if (mov_white) // E>4 15;KE

   {

      if (ch==pW) // ?@>AB0O 15;0O

      {

         put_hew_white(x-2,y+2,x-1,y+1,n_move,set); // @C1:0 =0;52> 225@E

         put_hew_white(x+2,y+2,x+1,y+1,n_move,set); // @C1:0 =0?@02> 225@E

         put_hew_white(x-2,y-2,x-1,y-1,n_move,set); // @C1:0 =0;52> 2=87

         put_hew_white(x+2,y-2,x+1,y-1,n_move,set); // @C1:0 =0?@02> 2=87

      }

   }

   else// E>4 G5@=KE

   {

      if (ch==pB)  // ?@>AB0O G5@=0O

      {

         put_hew_black(x-2,y+2,x-1,y+1,n_move,set);

         put_hew_black(x+2,y+2,x+1,y+1,n_move,set);

         put_hew_black(x-2,y-2,x-1,y-1,n_move,set);

         put_hew_black(x+2,y-2,x+1,y-1,n_move,set);

      }

   }

   return(n_move>0);

}

//----------------------

void Class_position::put_hew_white(int x1,int y1,int x2,int y2,int& n_move,bool set)

{  // 70?8A0BL 2 ?>78F8N 4>?CAB8<K5 CAB0=>2:8 ?>A;5 @C1:8 15;>9 ?@>AB>9 H0H:>9

   if ((get_ch(x2,y2)==pB || get_ch(x2,y2)==dB) && get_ch(x1,y1)==NO)

   {

      if (set)

      {

         put_move(x1,y1,let);

         checkers[x1][y1].put(x2,y2);

      }

      n_move++;

   }

}

//----------------------

void Class_position::put_hew_black(int x1,int y1,int x2,int y2,int& n_move,bool set)

{   // 70?8A0BL 2 ?>78F8N 4>?CAB8<K5 CAB0=>2:8 ?>A;5 @C1:8 G5@=>9 ?@>AB>9 H0H:>9

   if ((get_ch(x2,y2)==pW || get_ch(x2,y2)==dW) && get_ch(x1,y1)==NO)

   {

      if (set)

      {

         put_move(x1,y1,let);

         checkers[x1][y1].put(x2,y2);

      }

      n_move++;

   }

}

//----------------------

type_ch Class_position::get_ch(int x,int y)

{ // ?@>G8B0BL :>>@48=0BC 2 ?>78F88

   if (x>=0 && x<8 && y>=0 && y<8)return(checkers[x][y].get());

   return(OFF); // 5A;8 :>>@48=0BK 70 ?@545;0<8 4>A:8

}

//----------------------

type_move Class_position::get_move(int x,int y)

{ // ?@>G8B0BL B8? E>40 H0H:8

   if (x>=0 && x<8 && y>=0 && y<8)return(checkers[x][y].get_move());

   return(off); // 5A;8 :>>@48=0BK 70 ?@545;0<8 4>A:8

}

//----------------------

type_ch Class_position::put_ch(int x,int y, type_ch ch)

{ // 70?8A0BL H0H:C 2 ?>78F8N

   if (x>=0 && x<8 && y>=0 && y<8)

   {

      if (ch==pB && y==0)ch=dB; // G5@=0O H0H:0 =0 =C;52>9  AB@>G:5 ?@52@0I05BAO 2 40<:C

      if (ch==pW && y==7)ch=dW; // 15;0O H0H:0 =0 ?>A;54=59 AB@>G:5 ?@52@0I05BAO 2 40<:C

      checkers[x][y].put(ch);

      return(ch);

   }

   return(OFF); // 2K2>48BAO ?@8 =54>?CAB8<KE :>>@48=0B0E 70?8A8

}

//----------------------

type_ch Class_position::del_ch(int x,int y) // C40;8BL H0H:C A ?>78F88

{ // DC=:F8O C40;O5B 8 2K2>48B B8? C40;5==>9 H0H:8

   type_ch ch=OFF; // 2K2>48BAO ?@8 =54>?CAB8<KE :>>@48=0B0E

   if (x>=0 && x<8 && y>=0 && y<8) // 5A;8 :>>@48=0BK 2 ?@545;0E ?>;O

   {

      ch=get_ch(x,y);

      checkers[x][y].put(NO,no,-1,-1);

   }

   return(ch);

}

bool Class_position::get_xy_hew(int i,int j,int& x,int& y)

{ //  ?@>G8B0BL 70?8A0==K5 =0 ?CAB>< ?>;5 :>>@4.A@C1;5==>9 H0H:8

   checkers[i][j].get(x,y);

   return(x>=0 && y>=0);

}

//-------------------------

void Class_position::set_hew(bool move_white,int x,int y)

{ // >B<5B8BL A@C1;5==CN H0H:C (87<5=8BL 5Q :>4 =0 2)

   if (move_white)

      position.put_ch(x,y,(type_ch)((int)position.get_ch(x,y)-2));

   else

      position.put_ch(x,y,(type_ch)((int)position.get_ch(x,y)+2));

}

//-------------------------

void Class_position::set_let_hew(bool white,int x,int y)

{  // =09B8 2>7<>6=K5 E>4K 4;O 40;L=59H59 @C1:8 2 @07=KE =0?@02;5=8OE

   //x,y - 8AE>4=>5 ?>;5 40<:8, :>B>@0O 1C45B 40;LH5 @C18BL

   

   set_let_hew_line( 1, 1,x,y,white); 

   set_let_hew_line( 1,-1,x,y,white); 

   set_let_hew_line(-1, 1,x,y,white); 

   set_let_hew_line(-1,-1,x,y,white); 

}

//-------------------------------

void Class_position::set_let_hew_line(int i1,int i2,int x,int y,bool white)

{  // =09B8 2>7<>6=K5 E>4K 4;O 40;L=59H59 @C1:8 2 >?@545;5==>< =0?@02;5=88

   //x,y - 8AE>4=>5 ?>;5 40<:8, :>B>@0O 1C45B 40;LH5 @C18BL

   //          0;3>@8B<:

   // ?@>A<>@5BL 2 MB>< =0?@0;5=88 2>7<>6=K5 CAB0=>2:8 40<:8

   // >B :064>3> 2>7<>6=>3> E>40 >?@545;8BL, 5ABL ;8 40;LH5 @C1:0?

   // 5A;8 5ABL, CAB0=>28BL =0 MB>< 2>7<>6=>< E>45 ?5@5<5==CN @C1:0 exist_hew=true

   // ?>A;5 >:>=G0=8O ?@>A<>B@0 2A5E 2>7<>6=KE E>4>2 2 MB>< =0?@02;5=88, 8, 5A;8 1K;8 @C1:8, B>

   // A=>20 ?@>A<>B@5BL 2>7<>6=K5 E>4K, 8 

   // B0<, 345 1K;0 CAB0=>2;5=0 exist_hew=false, C1@0BL 2>7<>6=K9 E>4, 0

   // B0<, 345 exist_hew=true, CAB0=>28BL exist_hew=false (B.5. >AB028BL MB>B 2>7<>6=K9 E>4)

   bool yes_hew=false;

   for(int i=2;i<8;i++)

   {

      int x1=x+i1*i;

      int y1=y+i2*i;

      if (get_move(x1,y1)==let)

      {

         int x2,y2;

         get_xy_hew(x1,y1,x2,y2);

         bool find_hew=find_hew_king(white,x1,y1,x2,y2);

         yes_hew=yes_hew || find_hew;

         if (find_hew)put_exist_hew(x1,y1,true);

      }

   }

   //...........................

   if (yes_hew)

      for(int i=0;i<8;i++)

      {

         int x1=x+i1*i;

         int y1=y+i2*i;

         if (get_ch(x1,y1)!=OFF)

            if (get_exist_hew(x1,y1))

               put_exist_hew(x1,y1,false);

            else

               put_move(x1,y1,no,-1,-1);

      }

}

//-------------------------------

bool Class_position::find_hew_king(bool white,int x,int y,int xr,int yr)

{  // =09B8 2>7<>6=CN @C1:C A ?CAB>3> ?>;O 4;O 40<:8, 8A:;NG0OO >1@0B=>5 =0?@02;5=85

   int n_move=0;

   

   if (white) // E>4 15;KE

   {

      if (!(xr>x && yr>y))find_hew_white_king( 1, 1,x,y,n_move);

      if (!(xr>x && yr<y))find_hew_white_king( 1,-1,x,y,n_move);

      if (!(xr<x && yr>y))find_hew_white_king(-1, 1,x,y,n_move);

      if (!(xr<x && yr<y))find_hew_white_king(-1,-1,x,y,n_move);

   }

   else // E>4 G5@=KE

   {

      if (!(xr>x && yr>y))find_hew_black_king( 1, 1,x,y,n_move);

      if (!(xr>x && yr<y))find_hew_black_king( 1,-1,x,y,n_move);

      if (!(xr<x && yr>y))find_hew_black_king(-1, 1,x,y,n_move);

      if (!(xr<x && yr<y))find_hew_black_king(-1,-1,x,y,n_move);

   }

   

   return(n_move>0);

}

//----------------------

bool Class_position::find_set_hew_king(bool white,int x,int y,bool set=true)

{  // =09B8 2>7<>6=CN @C1:C 4;O 40<:8

   int n_move=0;

   type_ch ch=position.get_ch(x,y);

   if (white) // E>4 15;KE

   {

      if (ch==dW) // 40<:0 15;0O

      {

         find_hew_white_king( 1, 1,x,y,n_move,set);

         find_hew_white_king( 1,-1,x,y,n_move,set);

         find_hew_white_king(-1, 1,x,y,n_move,set);

         find_hew_white_king(-1,-1,x,y,n_move,set);

      }

   }

   else // E>4 G5@=KE

      if (ch==dB) // 40<:0 G5@=0O

      {

         find_hew_black_king( 1, 1,x,y,n_move,set);

         find_hew_black_king( 1,-1,x,y,n_move,set);

         find_hew_black_king(-1, 1,x,y,n_move,set);

         find_hew_black_king(-1,-1,x,y,n_move,set);

      }

   return(n_move>0);

}

//----------------------

void Class_position::find_hew_white_king(int i1,int i2,int x,int y,int& n_move,bool set=false)

{  // 15;0O 40<:0 1C45B @C18BL, 5A;8 24>;L ;8=88 5ABL A=0G0;0 ?CABK5 ?>;O(8;8 8E =5B), 

   // 70B5< 5ABL G5@=0O, 0 ?>A;5 =5Q >4=0 8;8 =5A:>;L:> ?CABKE

   bool find_black=false;

   int x1=-1,y1=-1; // :>>@4. A@C1;5==>9 H0H:8

   for(int i=1;i<8;i++)

   {

      type_ch ch=position.get_ch(x+i*i1,y+i*i2);

      if (!find_black) // =0G0;> ?>8A:0

      {

         if (ch==OFF)break; // 2KH;8 70 ?@545;K 4>A:8, :>=5F

         if (ch==NO)continue; // =0945=> ?CAB>5 ?>;5

         if (ch==pW  || ch==dW)break;  //=0945=0 15;0O, :>=5F

         if (ch==pBr || ch==dBr)break;  //=0945=0 G5@=0O A@C1;5==0O, :>=5F

         if (ch==pB  || ch==dB) // =0945=0 G5@=0O, :>B>@CN =C6=> @C18BL

         {

            x1=x+i*i1; // 70?><=8BL :>>@4.A@C1;5==>9 H0H:8

            y1=y+i*i2;

            find_black=true;

         }

      }

      else // 1K;0 =0945=0 G5@=0O H0H:0, ?@>25@8<, 5ABL ;8 70 =59 ?CABK5 ?>;O. B<5B8< 8E

      {

         if (ch!=NO)break;// 5A;8 =5 ?CAB>5 ?>;5, :>=5F

         if (set)

         {

            put_move(x+i*i1,y+i*i2,let);

            checkers[x+i*i1][y+i*i2].put(x1,y1);

         }

         n_move++;

      }

   }

}

//------------------------------

void Class_position::find_hew_black_king(int i1,int i2,int x,int y,int& n_move,bool set=false)

{  // G5@=0O 40<:0 1C45B @C18BL, 5A;8 24>;L ;8=88 5ABL A=0G0;0 ?CABK5 ?>;O(8;8 8E =5B), 

   // 70B5< 5ABL 15;0O, 0 ?>A;5 =5Q >4=0 8;8 =5A:>;L:> ?CABKE

   bool find_white=false;

   int x1=-1,y1=-1; // :>>@4. A@C1;5==>9 H0H:8

   for(int i=1;i<8;i++)

   {

      type_ch ch=position.get_ch(x+i*i1,y+i*i2);

      if (!find_white) // =0G0;> ?>8A:0

      {

         if (ch==OFF)break; // 2KH;8 70 ?@545;K 4>A:8

         if (ch==NO)continue; // =0945=> ?CAB>5 ?>;5

         if (ch==pB  || ch==dB)break;  //=0945=0 G5@=0O, :>=5F

         if (ch==pWr || ch==dWr)break;  //=0945=0 15;0O A@C1;5==0O, :>=5F

         if (ch==pW  || ch==dW) // =0945=0 15;0O, :>B>@CN =C6=> @C18BL

         {

            x1=x+i*i1; // 70?><=8BL :>>@4.A@C1;5==>9 H0H:8

            y1=y+i*i2;

            find_white=true;

         }

      }

      else // 1K;0 =0945=0 15;0O H0H:0

      {

         if (ch!=NO)break;// 5A;8 =5 ?CAB>5 ?>;5, :>=5F

         if (set)

         {

            put_move(x+i*i1,y+i*i2,let);

            checkers[x+i*i1][y+i*i2].put(x1,y1);

         }

         n_move++;

      }

   }

}

//=====================================

void Class_position::out_press(int i,int j,type_ch ch)

{  // 2K2>4, ?@8 =060B88 =0 :;5B:C A H0H:>9

   set_begin_move(i,j); // 70?8A0BL =0G0;> E>40

   put_move_white(); // 70?8A0BL 2 ?>78F8N >G5@54=>ABL E>40

   put_move_white_ann(); // 70?8A0BL 2 ?>78F8N >G5@54=>ABL E>40 4;O 0==>B0F88

     

   if (move_White)put_nom_move(get_nom_move()+1); // :>340 E>4 15;KE, C25;8G8BL =><5@ E>40:

   put_ann(i,j); // 70?8A0BL 0==>B0F8N =0G0;0 E>40

   put_action(0); // =5B ?@5DD8:A0 ?5@54 =0G0;>< E>40



   press_ch.put(i,j,ch); // A>E@0=8BL :>>@4.=060B>9 H0H:8

   

   mas_position.put_mas(); // 70?8A0BL 2 <0AA82 >G5@54=CN ?>78F8N

   mas_position.out_anot(); // 2K25AB8 0==>B0F8N

   

   panel.out_pos(position); // 2K25AB8 ?>78F8N =0 4>A:C

}

//-----------------------

void out_order_move()

{ // 2K25AB8 >G5@545@>ABL E>40

   if (move_White)

   {

      ObjectSetString (0,name_next_move,OBJPROP_TEXT,"move White");

      ObjectSetInteger(0,name_next_move,OBJPROP_COLOR,clr_Text);

   }

   else

   {

      ObjectSetString (0,name_next_move,OBJPROP_TEXT,"move Black");

      ObjectSetInteger(0,name_next_move,OBJPROP_COLOR,clr_Fon_off);

   }

}

//---------------------------------

void put_button()

{

   ButtonCreate(but_del_all,shift_panel+223+8*di, 20,80,20,"Clean",10,clr_Fon_But1);

   ButtonCreate(but_beg,shift_panel+223+8*di, 60,80,20,"Begin");

   

   ButtonCreate(but_rev,shift_panel+223+8*di,100,80,20,"Revers",10,clr_Fon_off);

   out_clr_but_revers();

   

   LabelCreate(0,but_left,0,shift_panel+240+8*di,160,"?","wingdings",20,clr_Text);

   LabelCreate(0,but_right,0,shift_panel+285+8*di,160,"@","wingdings",20,clr_Text);

   mas_position.set_arrow(); //2K25AB8 AB@5;:8



   ButtonCreate(but_ust,shift_panel+230+8*di,190,65,20,"Game",11,clr_Fon_But);

   if (game)

   {

      out_next_move();

      out_order_move(); // 2K25AB8 >G5@54=>ABL E>40 =0 M:@0=

   }

   else

   {

      ObjectDelete(name_next_move);

      ObjectSetString (0,but_ust,OBJPROP_TEXT,"Set");

      ObjectSetInteger(0,but_ust,OBJPROP_BGCOLOR,clrRed);

      ObjectSet(but_checkers,OBJPROP_XDISTANCE,shift_panel+237+8*di);

      if (ust_checkers==pW || ust_checkers==pB)

         ObjectSet(but_checkers+"t",OBJPROP_XDISTANCE,shift_panel+237+8*di+25);

      else

         if (ust_checkers==dW || ust_checkers==dB)

            ObjectSet(but_checkers+"t",OBJPROP_XDISTANCE,shift_panel+237+8*di+21);

   }

   

   ButtonCreate(but_clr,shift_panel+350+8*di,20,50,20,"Cln",10,clr_Fon_But1);

   ButtonCreate(but_put,shift_panel+350+8*di,60,50,20,"Put");

   //......................

   ButtonCreate(but_full_anot,shift_panel+450+8*di,20,60,20,"Short");

   out_txt_but_anot();

   //.....................

   ObjectDelete("chclose");

   ButtonCreate("chclose",shift_panel+530+8*di,20,20,20,"X",10,clrCrimson,clrWhite,"Arial Black");

}

//--------------------------------------

void out_next_move()

{

   LabelCreate(0,name_next_move,0,shift_panel+222+8*di,240,"move White","Arial Black",8,clr_Text,0,ANCHOR_LEFT_LOWER);

}

//-----------------------

void out_ust_ch_cicle(type_ch& ch)

{  // CAB0=>28BL A;54CNI89 B8? H0H:8 2 4>?. ?>;5 (?> F8:;C)

   switch(ch)

   {

      case pW : ch=pB;out_prost_ust(ch);break;  // ?>A;5 ?@>AB>9 15;>9 - G5@=0O ?@>AB0O

      case pB : ch=dW;out_dam_ust(ch);break;    // ?>A;5 ?@>AB>9 G5@=>9 - 40<:0 15;0O

      case dW : ch=dB;out_dam_ust(ch);break;    // ?>A;5 40<:8 15;>9 - 40<:0 G5@=0O

      default : ch=pW;out_prost_ust(ch);break;  // 8=0G5 ?@>AB0O 15;0O

   }

}

//---------------------

void out_prost_ust(type_ch ch)

{ // 2K25AB8 ?@>ABCN 2 4>?>;=8B5;L=>5 ?>;5

   color clr=clrWhite;

   if (ch==pB)clr=clrBlack;

   int n=(int)ObjectGet(but_checkers,OBJPROP_XDISTANCE);

   LabelCreate(0,but_checkers+"t",0,n+25,224+64/2,"l","wingdings",40,clr);

}

//-----------------

void out_dam_ust(type_ch ch)

{ // 2K25AB8 40<:C 2 4>?>;=8B5;L=>5 ?>;5

   color clr=clrWhite;

   if (ch==dB)clr=clrBlack;

   int n=(int)ObjectGet(but_checkers,OBJPROP_XDISTANCE);

   LabelCreate(0,but_checkers+"t",0,n+21,224+64/2,"m","wingdings",35,clr,-70);

}

//------------------------

void Class_mas_pos::out_anot()

{ // 2K25AB8 0==>B0F8N

   int X=shift_panel+480+8*di,Y=60;

   int max_str=15; // <0:A.:>;.AB@>: 4;O 2K2>40 =0 M:@0=

   int all_str=0;

   int sh=0,shift=80;

   int max_len=9;

     

   Class_position p;

   int n=-1,n1=-1,n2=n1,n3=0;;

   string s="",s1="";

   bool out=false,m,move_W=false;

   //...............................................

    // ?>AG8B0BL :>;.AB@>: >B =0G0;0 4> B5:.?>78F88 AB5:0

   get_mas(tek_pos-1,p);

   int end_str=p.get_nom_move();

   //...............................................

   init_out_anot();

   for(int i=0;i<tek_pos;i++)

   {

      get_mas(i,p);

      int N=p.get_nom_move();

      if (n!=N)

      {

         n=N;

         n1=n2; // n2 <>65B 1KBL 1>;LH5 n1 (5A;8 C 15;KE 1K;0 4;8==0O AB@>G:0, B> 1K; ?5@5=>A AB@>:8)

         n1++;

         n2++;

         

         move_W=p.get_move_white_ann();

         m=move_W;

         if (move_W)

         {

            sh=0;

            if (full_anot)

               s=(string)n+(n<10?".  ":".")+p.get_ann();

            else

               s=(string)n+(n<10?".  ":".")+CharToStr(p.get_ann(0));

         }

      }

      else

      {

         m=p.get_move_white_ann();

         if (m!=move_W)

         {

            if (full_anot)

               s=p.get_ann();

            else

               s=CharToStr(p.get_ann(0));

            sh=shift;

            move_W=m;

         }

         else

            if (full_anot)

               s=s+p.get_action()+p.get_ann();

            else

               if (p.end)

                  s=s+(p.get_action_uchar()=='-'?"":p.get_action())+p.get_ann();

               else

                  s=s+p.get_action()+CharToStr(p.get_ann(0));

      }

      if (!move_W && StringLen(s1)>max_len)n2=n1+1; //?5@5=>A, 5A;8 E>4 G5@=KE, 0 C 15;KE 1K;0 4;8==0O AB@>G:0

      //......................

      out=false;

      n3=n2-(end_str-max_str);

      if (end_str-n2 < max_str)

      {

         if (end_str<max_str)n3=n2;

         out=true;

      }

      //......................

      if (out && n>0)LabelCreate(0,pref+StringConcatenate("an",(int)m,n),0,X-30+sh,Y+20*n3,s,"Arial",10,clr_Text,0,ANCHOR_LEFT_LOWER);

      s1=s;

   }

}

//--------------------------------

void Class_mas_pos::init_out_anot()

{ //>G8AB8BL 0==>B0F8N 

   ObjectsDeleteAll(0,pref+"an");

}

//=====================================================

void Class_micro_pos::out_all_micro_pos()

{ // 2K25AB8 2A5 <8:@>?>78F88

   ObjectsDeleteAll(0,pref+"m");

   //..........................

   for(int i=0;i<n_micro_pos;i++)

   {

      LabelCreate(0,but_npos+(string)i,0,shift_panel+340+8*di,45*(i+1)+60,(string)(n_micro_pos-i),"Arial",10,clr_Text); // F8D@0

      LabelCreate(0,but_del_pos+(string)i,0,shift_panel+410+8*di,45*(i+1)+60,"X","Arial Black",12,clr_Text); // :@5AB8:

      

      out_micro_pos(shift_panel+390+8*di,45*(i+1)+40,i);

   }

}

//----------------------------

void Class_micro_pos::out_micro_pos(int x,int y,int n)

{  // ?5@5?8A0BL ?>A;54=NN ?>78F8N  87 <0AA820 ?>78F89 2 <8:@>?>78F8N

   int di_=5;

   out_Rect(8,8,x-di_*7-1+0,y,di_*8+4,clr_Osn,"m"+(string)n,1,clrNONE,BORDER_FLAT,CORNER_LEFT_UPPER,STYLE_SOLID,false,0);// >A=>20



   Class_mas_pos m_pos;

   get(n,m_pos);

   if (m_pos.get_tek_pos()<1)return;

   

   Class_position pos;

   m_pos.get_mas(m_pos.get_tek_pos()-1,pos);

   

   for(int j=0;j<8;j++)

      for(int i=(int)MathMod(j,2);i<8;i+=2)

      {

         int xi=x-di_*(7-i);

         int yi=y+di_*(7-j);

         color clr=0;

         int i1=i;

         int j1=j;

         if (revers)

         {

            i1=7-i;

            j1=7-j;

         }

         type_ch ch=pos.get_ch(i1,j1);

         if (ch==pW || ch==dW)

         {

            clr=clrWhite;

            out_Rect(i1,j1,xi,yi+1,di_+2,clr,"m"+(string)n,clrNONE,0,BORDER_FLAT,CORNER_LEFT_UPPER,STYLE_SOLID,false,0);

         }

         else

            if (ch==pB || ch==dB)

            {

               clr=clrBlack;

               out_Rect(i1,j1,xi,yi+1,di_+2,clr,"m"+(string)n,clrNONE,0,BORDER_FLAT,CORNER_LEFT_UPPER,STYLE_SOLID,false,0);

            }

            else

               ObjectDelete(0,pref+StringConcatenate("m",n,i1,j1));

      }

}

//-----------------------------

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---