SEclone basic classes for tagging

 

The table of candidates TZPTLN

 

I name that table the table of candidates because it fits better with SE logic.

In fact, the table is designed to contains groups of candidates as well and it could be that a second table will be opened later to process the “dynamic” chains.

 

In SE clone, that table is loaded once per cycle. In each step of the chains search, it must be reset to initial (not tagged)

 

Many key functions are based on  that table,

 

The class ZPTLN defining a group of candidates is very simple

 

class ZPTLN

{public

USHORT   ch,  // digit

           m,   // tag (default 0)

           ig;  // ig indice zgs

 

inline void Charge(USHORT i,USHORT che) {m=0;ig=i;ch=che;}

inline ZINFL* GetZ(){return  &zgs.z[ig];}

inline void GetChZ(USHORT & cr,ZINFL &zr) {cr=ch;zr=zgs.z[ig];}

inline void GetChZiz(USHORT & cr,ZINFL &zr,USHORT & izr){cr=ch;izr=ig; zr=zgs.z[ig];}              

void Image() {E$.Esp();E$.E(ch+1);zgs.z[ig].ImagePoints();E$.E('.');mms.ev(m); }

};

 

 

The main table is defined in the class TZPTLN, one member zptln

The size of the table is set to 2000. 350 should be enough, but we could need more for future extensions;

 

That class is far from being cleaned.

To make easier entry in the code, functions have been spread in several .cpp files, pushing uncleaned part in a specific file.

 

In the .h file are the routines for loading

The file tpt0.cpp has the routines used to tag and to generate weak links

The files tpt1.cpp and tpt2.cpp have functions  to find chains and eliminations within a layer.

The file tpt_length.cpp  has functions to work out a chain in SE mode

The file tpt.cpp has both new functions and old ones, some of them obsolete;

 

#define zpln_lim 2000

 

class TZPTLN

{ public:ZPTLN zp[zpln_lim];

  USHORT ip,ipbase,

         tag_to_point[800],  // direct link set when tagging

         tag_count[800],     // number of points per tag

      mfinc,ptsch[100],iptsch;

  USHORT mch[20],ich,el, nmch,length;       // pour gen chx

  ZINFL zf[10],zptsch[100],zel;

  PATH_BLOC pathb1,pathb2;

  PATH pathr;

  inline void Init(){ip=1; mfinc=0;zp[0].m=0; };

 

  USHORT Chargexx(int ig,USHORT ch);  // obsolete, ex charge

  USHORT Charge0(){USHORT ir=ip; zp[ip++]=zp[0]; return ir;}

  USHORT Charge(USHORT ch,ZINFL z);

  void  InitCol() {for (int i=0;i<ip;i++)zp[i].m=0;

                   for(int i=0;i<800;i++) tag_to_point[i]=tag_count[i]=0;

                   }// not tagged

 

                     //==============TPT0

  void MarquerSolde() ;

  void Conflits(){}// obsolete

  void ConflitsCase();  

  void ConflitsChiffres(){for(USHORT ich=0;ich<9;ich++) ConflitsChiffre(ich); }

  void ConflitsChiffre(USHORT ch);  

  void ConflitsD();

  void GenereZcx();     

 

                   //========= TPT1 work within a layer

 

  void Impossible(int base);

  void Impossible_loop(USHORT p1,USHORT p2);

  int Chain_layer(USHORT ptd,USHORT ptf);

  void SuppMarque(USHORT mm,int direct=0);  

 

                  //============ TPT2 continued

  int Xcycle(); // look for xcycle made of strong links

 

  void PrintPath(USHORT * tp,USHORT np)

      {if(!o$.ot) return; E$.Echem();

       for(int i=0;i<np;i++) {zp[tp[i]].Image();

                                 if(i<np-1) if(i&1)E$.Esl(); else E$.Ewl(); }

       E$.Enl();}

 

                  // tpt_length computing equivalent SQE length

  int Find_Length(PATH & path,USHORT start);

  void Find_Last(PATH & pthm,PATH & pthw);

  void Find_First(USHORT m1,USHORT m2,USHORT start);

  void Find_FirstD(USHORT m1,int i,USHORT start);

  void LengthStep(USHORT m1,USHORT m2);

  void LengthStepD(USHORT m1,int i);

 

 

                 //============ TPT

 

   USHORT GetPoint(int i8,int ch)

         {for(USHORT i=1;i<ip;i++)

           if((zp[i].ig==i8 ) && (zp[i].ch==ch )) return  i;  return 0;}

 

 

 void ChargeAvecComplementGroupe(USHORT i); 

 USHORT CreerAvecComplement(USHORT che,ZINFL z);

 

  void FusionPts(USHORT p1,USHORT p2);

  //int ForcePoint(int i){return SuppMarque(zp[i].m^1);}

  void SuppPoint(int i){SuppMarque(zp[i].m); }

  int SuppMarques(CB1024 & zzs );

  int SuppZCh(ZINFL z,USHORT ch);

  USHORT Getm(int i){return zp[i].m;}

  ZINFL* GetZ(int i){return zp[i].GetZ();}

  void GetChZ(USHORT & cr,ZINFL &zr,int i) {zp[i].GetChZ(cr,zr);}

  void GetChZiz(USHORT & cr,ZINFL &zr,USHORT &izr,int i) {zp[i].GetChZiz(cr,zr,izr);}

//  USHORT Marque(USHORT m,USHORT i)   {return  zp[i].Marque(m);}

  USHORT GetFirstM(USHORT m);    

  USHORT GetPoint(ZINFL z ,int ch);

  void SetPoint(USHORT i,UCHAR &ch,ZINFL &z );

  USHORT Getm (ZINFL z ,CB9CH ch);

 

 

  int GroupeConflitDetail();

  USHORT Getch(int i){return zp[i].ch;};

 

  // specifically prepared for SE clone

  int XcycleTag(int tag);

 // int Self_Clean(USHORT m1,USHORT m2,int go=0); // xcycle with self cleaning

 

  int Xchain(int go=0); // look for xchain made of strong links

  int XchainTag(int tag,int go);

 

 

  void Image(int i) {zp[i].Image();  }

 

  void ImageM(int m,int=0)

          {USHORT w=tag_to_point[m];

           if (!w)  {mms.ev(m);return;}// nothing

           zp[w].Image(); }

 

  void ImageMcb(CB1024 cb)

             {for(int i=2;i<col;i++) if(cb.On(i)){ImageM(i);E$.Esp();}}

 

  void ListeMarques();

  void ListeMarquesPoints();

  void GetMarquesPoints(CB1024 & rr);

  void ImageDeuxM(USHORT * m);

  void ImageAllM(USHORT m);

  void ImageET(USHORT m,USHORT *md, USHORT *p,int court=0); 

  void ImageET (USHORT *p);

  void ImagePoints(CB1024 v,char * lib)

    {if(!o$.ot) return; E$.E(lib);

    for(int i=1;i<ip;i++) if(v.On(i))  {E$.Esp();zp[i].Image();}

        E$.Enl();     }// de zl liste points

  void Liste();

}zpln; 

 

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

USHORT TZPTLN::Chargexx(int ie,USHORT ch)  //On ne charge pas les doubles

{for (int i=1;i<ip;i++) { if((zp[i].ch==ch) && (zp[i].ig==ie)) return i;  }

 if(ip<zpln_lim){ zp[ip++].Charge(  ie,ch);

               return (ip-1);}

 E$.Elimite("TZPLN"); return -1;}

 

USHORT TZPTLN::Charge(USHORT che,ZINFL z)

{int ix=zgs.Charge(z); return Chargexx(ix,che);}