SEclone tagging basic


TCHOIX is our last basic class to consider.


Again, we have a class designed for a wider scope, but, unless I missed something, we have already some final data in that first step of the implementation.


TCHOIX is designed to handle sets of tags.


In Sudoku Explainer, a set of tags describe either a cell or all occurrences of a digit in a row/column/box.


I doubt we will need more.


Again, I expect a strong limitation is the generation of derived weak links, not active up to now;


In that first step,  functions  active are,

  the search of eliminations thru a “choice” (a set of tags) in the aligned pair exclusion process.

  A specific derivation to comply with aligned pair triplet exclusion


So I’ll give, as for TZCF, a limited view of the existing code

We start in the file choix.h


ZXCB is in fact a buffer to store tags and candidates index in TZPTLN. This was done to handle a wide range of dimensions for sets. I kept it here.



#define zcxb_lim 100000

class ZCXB   // buffer stockage marques et points

{public: USHORT zs[zcxb_lim],izs;

 void Init(){izs=0;}

 void Get(USHORT *(& ps),int n);



ZCHOIX is a set (cell of row/column/box + digit for us)

Again I skip all data unused here


class ZCHOIX


 USHORT *tm,  // taggs and cnadidates in index to TZPTLN


 int Prepare (USHORT * mi,USHORT nmi,UCHAR ty, USHORT tye,USHORT ixe);

 void GetMarques(CB1024& ms)// init à la charge de l'appelant

           {for(int i=0;i<nm;i++) ms.Set(tm[i]);}

 int Doublon(int n,CB1024 mw)

             {if(n-nm) return 0; CB1024 mw0;GetMarques(mw0);return(mw==mw0);}


 void PrintInterditSimple(USHORT mi,USHORT derive);


 int ImageSimple();

 int Interdit(int nmx,int ftyp,CB1024 &wi);


 void ImageBasexx(int saut=0);

 void ImageBase(){if(!ImageSimple()) ImageBasexx();}

 void ImageM(USHORT  m);

 void Image(int saut=1,int detac2=0 );


} ;



And now TZCHOIX the main table in the file tchoix.h reduced to the minimum we need to understand what is going on



#define zcx_lim 1000

 class TZCHOIX    

 { public:   

   USHORT *tmo;

   ZCHOIX zc[10000];//,zwi,zwj,zw;

   USHORT izc,nmmax,ie,je,nni,nnj,avecderive;    


   CB1024 ztgo, tce[20]; 


    void Init(){izc=1;zcxb.Init();nmmax=3;};     

    int Charge (USHORT * mi,USHORT nmi,UCHAR ty,USHORT tyind);

       int doublon(int n,CB1024 mw)

            {for(int i=1;i<izc;i++)  if(zc[i].Doublon(n,mw))return 1; return 0 ;}


    int InterditChoixSeul(int tri) ;  


    void PrintInterdits(CB1024 & a_faire ,USHORT derive  );


    int ImageRemonte(TCF & conflit,USHORT * m);

     void ImageBase();

    void Image(int i,int saut=0){zc[i].Image(saut);}

    void AddSyuTriplet();

  }zcx ; 



First key function, derived from  the similar function in the solver located in tchoix_adn.cpp


That function locate sets where a tag is in conflict with all tags except one.

This is a “derived weak link”.

As an aligned triple is not to difficult to decipher, no special care is taken to trace back the nested chain. 



// specific to aligned triplet exclusion

// only cells of three candidates and very short paths

void TZCHOIX::AddSyuTriplet() // soryu 1 et le reste

{E$.E("debut add soryu ");E$.Enl(zcf.ic);   CB1024 * t= zcf.h.d.t;

 for (ie=1;ie<izc;ie++)                        

   {if((zc[ie].nm-3)|| zc[ie].type) continue// cell 3 digits only

    USHORT * tmo=zc[ie].tm; nni=zc[ie].nm ; 

    for(int i=0;i<nni;i++)        {USHORT mm=tmo[i];   tce[i]=t[mm]; }

    CB1024 tcf2,tcf2f;   tcf2.InitUn();

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

      {tcf2f=tcf2;  if(i<nni)for(int k=i+1;k<nni;k++) tcf2f=tcf2f&tce[k];


         {for(USHORT j=2;j<col;j++)  // on fait maigrir

           {if((!tcf2f.Isch(j))|| tce[i].Isch(j)) continue;

            //CB1024 ww= zcf.h.d.t[j] & tcf2f; if(ww.NonNul())continue;

                     if(zcf.ChargeOUid( zc[ie].tm[i],j,33,ie,(i+1),0) ) zc[ie].soryus|=1<<i;}


       tcf2=tcf2&tce[i];if(tcf2.Nul()) break;}




Secong t key function, also derived from  the similar function in the solver located in tchoix.cpp



That function locate sets where a tag is in conflict with all tags , leading to an elimiantion

Applied to Aligned pair exclusion is limited to chains crossing one pair..



 int TZCHOIX::InterditChoixSeul(int tri)

 {CB1024 tbt;   int ir=0; 

  for (int ie=1;ie<izc;ie++)     // tous liens actifs

   {int n=zc[ie].nm; USHORT *tm=zc[ie].tm ;  tbt.InitUn();

    for(int  i=0;i<n;i++) tbt&= (* zcf.Getd(tm[i]));

    if(tbt.NonNul()) // candidate(s) to clear found

       {for(int  i=2;i<col;i++)if(tbt.On(i))

             {int aig=0;zcf.h.d.Parents(i);

              if(op0){zcf.h.d.parents.ImageMarques("parents =",0);E$.Enl();}


                 for(int  j=0;j<n;j++)//check for length path <4 for aligned pair

                     { CB1024 ww=zcf.h.d.t[tm[j]] & zcf.h.d.parents;ww.Set(i);


                       USHORT wl= zcf.h.dp.length;

                       if(wl>3 || wl<1)         {aig=1;break; }


              if(aig) continue





          if(ir) return 1;// stop after the first active set

        } // end  for if

    } // end ie

 return ir; }