SEclone basic classes for tagging

The table of strong links TZL continued

 

 

Various call to the search of a piece of path,  liens2.cpp

 

Here are specific call to the previous function

 

 Chemin ()

 

Works on a set of “start candidates”  and a set of “end candidates” assuming each set has only one tag and the 2 tags are in the same layer.

 

Each pair of candidates has to be considered and, at the end, the shortest path is

 

 

 

LoopThru() 

 

looks for a loop crossing a specific candidates (identified as a source of elimination). Here, t=we no trap, we just cut the process in 2 pieces to forc a _ > b  first.

The same problem in tag mode will be done in a different way.

 

 

/* a set of start candidates to a set of ending candidates

   we are looking for the overeall shortest path

   p3 is a point that must not be in the path  */

 

int TZL::Chemin(CB1024 &ptsd,CB1024 &ptsf,USHORT p3)

{USHORT lgth=100;

 iskip=p3; // that point must not be in the path     

 for(int i=0;i<zpln.ip;i++) if(ptsf.On(i))//all end points

  {for(int j=0;j<zpln.ip;j++) if(ptsd.On(i))//all start points

     {GoDirect(j,i);

         if(length<lgth) {lgth=length; Copy_Path(1);}

     }

  }

 if(length<1 || length>50) return 0;

 pathr[1].PrintPath();//zpln.PrintPath(mchr2,ichbonr2);

 Copy_Back(1);

 return length;  }

 

 

 

/* we have identified an indirect elimination within a layer

   must be a loop crossing the 2 candidates

   but they have complementary tagging, so must link

   some candidates in strong link with  p2

   here p3 must be outside the loop*/

 

 int TZL::Loop_thru(USHORT p1,USHORT p2,USHORT p3)

 {// find first candidates in contact with p2 and in loop with p1

  // no yet seen if this comes thru an equivalence link

  if(op1) return 0;

  iskip=p3; // unauthorized all along that process

  USHORT *ti=tdir[p2].ti,iti=tdir[p2].iti,tf[4],itf=0,px,lgth=100,lgth2;

  for(int i=0;i<iti;i++) // collect valid strong links in P2

   {px=ti[i]; if(px==p3) continue;

       if(itf<4) tf[itf++]=px;

   }

   if(itf<2) return 0;

 //  Now try all possible  p1 -> p2a "_ p2 _" p2b -> p1

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

     {lgth2=LoopD(p1,p2,p3,tf[i],tf[j]); if(!lgth2) continue;

      if(lgth2 && lgth2<lgth){lgth=lgth2; Copy_Path(1);} }

 if(lgth<0 || lgth>50) return 0; 

 pathr[1].PrintPath();//zpln.PrintPath(mchr2,ichbonr2); // print the good loop

 Copy_Back(1);

 return lgth; }

 

 

 

 int TZL::LoopD(USHORT p1,USHORT p2,USHORT p3,USHORT p2a,USHORT p2b)

 {GoDirect(p1, p2a);

  if(length<1) return 0; // no way without p3

        // we continue with a built "no way" back condition 

 path1.Add(p2); path1.Add(p2b);//mch[ichbon++]=p2;mch[ichbon]=p2b;

 ich=path1.ipth-1;   CB1024 wdone; wdone.Init();

 for(int i=0;i<=ich;i++) {done[i].Init(); USHORT x=path1.Get(i);

                          done[i].Set(x); 

                          if(i) wdone.Set(x);}

 mmfin=p2; done[ich]=wdone;// all history except start (if p2==p1)) in it

 length=100; // reset length to nothing found;

 Direct_Step();

 if(length<1 || length>50) {length=0;return 0;}

 Copy_Back(0); // get the final path in mch

 return length;}

 

 

HiddenKite,  liens3.cpp

 

 

HiddenKite() 

 

We found a contradiction in a layer (row; column; box) . We can find a Kite base on that contradiction. Such kite effect is hidden in the layer.

 

 

/* we have identified a contradiction within a layer

   p1;p2 ch  is the contradiction

   it can be a hidden kite, then the shortest path we can find to an elimination

   we look for elimination from the nearby candidates

*/

 int TZL::HiddenKite(int p1,int p2,USHORT ch)

 {USHORT *tp1=tdir[p1].ti,ip1=tdir[p1].iti,

         *tp2=tdir[p2].ti,ip2=tdir[p2].iti;

 for(int i=0;i<ip1;i++) for(int j=0;j<ip2;j++)

   {if(tp1[i] == tp2[j]) continue// not the same candidate

    USHORT ig1=zpln.zp[tp1[i]].ig,

              ig2=zpln.zp[tp2[j]].ig; // the 2 cells

    ZINFL zw=t81f[ig1].z & t81f[ig2].z & jdk.c[ich]; // target

       if(zw.Nul()) continue; // if target not empty we go

       if(tchain.Chaine(5,0))      {tchain.Add_Print(zw,ch); return 1;}

   }

return 0;}