src/puzzle.cpp
/*
Now looking for multi chains eliminations if any
the bfs must contain all candidates killed by the main assumption
and the source of all new strong links used

   here again, still some work to meet serate spec (same puzzle as nested forcing)
  .2..5...94....9......2..64.2..6....4..8....7.9..5....6.1..2....6..9....2......3..

[] 8r1c4 ->  ~8r3c6 ->  ~8r3c5 ->  8r3c9 ->  ~1r3c9
[] 8r7c4 ->  ~8r7c1 ->  8r9c1 ->  ~8r7c9 ->  ~8r9c9 ->  8r3c9 ->  ~1r3c9
[] 8r9c4 ->  ~8r9c1 ->  8r7c1 ->  ~8r9c9 ->  ~8r7c9 ->  8r3c9 ->  ~1r3c9

here serate stops at 8r3c9 which is correct
but concludes in once ~1r3c9 same trick as in the forcing chain
saving in total 4 in the count
skfr should save 3 in that situation

*/
Now looking for multi chains eliminations if any
the bfs must contain all candidates killed by the main assumption
and the source of all new strong links used





here serate stops at 8r3c9 which is correct
but concludes in once ~1r3c9 same trick as in the forcing chain
saving in total 4 in the count
skfr should save 3 in that situation
Now looking for multi chains eliminations if any the bfs must contain all candidates killed by the main assumption and the source of all new strong links used here serate stops at 8r3c9 which is correct but concludes in once ~1r3c9 same trick as in the forcing chain saving in total 4 in the count skfr should save 3 in that situation
void PUZZLE::NestedMultiLevel4(BFTAG & elims) {
   if(0){
	  EE.E("entry nested multi level 4 step ="); EE.Enl(npas);
	  Image((*cum),"cum debut",0);
	  Image(allsteps,"allsteps debut",0);
   }
   for(int ie = 1; ie < zcx.izc; ie++) {
		const SET &chx = zcx.zc[ie];
		int nni = chx.ncd, aig2 = 0; 
		BFTAG zt;
		zt.SetAll_1();
		zt = zt.FalseState();
		zt -= (*cum);
		if(chx.type - SET_base)
			   continue;
		for(int i = 0; i < nni; i++) {  
			USHORT cd = chx.tcd[i], j = cd << 1; 
			if(cum->On(j)) {
				aig2 = 1;
				break;
			}
			if(dn.t[j].On(j^1)) { 
				aig2 = 1;
				break;
			}
			zt.Clear(j^1); 
			if(cum->Off(j ^ 1)){
				zt &= dn.t[j];	
				zt -= dn.t[j].Inverse(); 
			}
		}
		if(aig2 || zt.IsEmpty() )
			continue;	
		if(0){
			EE.E("N Mul Lvl4 ");
			chx.Image(this,&EE);
			Image(zt," active for ",0);
			EE.Enl();
		}
		USHORT wtt[400],iwtt;
		zt.String(wtt,iwtt);
		for(int ii=0;ii<iwtt;ii++){
		    int i=wtt[ii];
			if(tsets[i])  
				continue;
			if(0){
				EE.E("gen multi ");chx.Image(this,&EE);
				EE.E(" for ");
				zpln.ImageTag(i);
				EE.Enl();
			}
			chain4_bf.SetAll_0();
			USHORT istored = 0, istoref = 0, tot_count = 0;
			for(int i2=0;i2<nni;i2++) {
				USHORT cd = chx.tcd[i2], j = cd << 1; 
				if(cum->On(j ^ 1)) {
					chain4_bf.Set(j ^ 1);
					continue;
				}
			   int ii=2;
               if(dpn.t[j].On(i)){ 
				   chain4_iresult=2;
				   chain4_result[0]=j;
				   chain4_result[1]=i;
			 	   back4_bfsource.SetAll_0();
			   }
			   else
				   ii=CaseNestedLevel4(j,i);
			   if(ii){ 
				    chain4_bf|=back4_bfsource;
				    if(0){
						EE.E("return from "); zpln.ImageTag(j);
						EE.Esp(); zpln.ImageTag(i);EE.Enl();
						zpln.PrintImply(chain4_result,chain4_iresult);
					}
				    istoref = tstore.AddChain(chain4_result,chain4_iresult);
				    if(!istored)
					   istored = istoref;
				   tot_count += chain4_iresult;			       
				}  
			   else { 
				   if(0){
					EE.E("\n\nm lvl4 failed for ");
					zpln.ImageTag(j);
					EE.Esp();
					zpln.ImageTag(i);
					chx.Image(this,&EE);
					EE.Enl();
					Image(dpn.t[j],"dpn",j);
					Image(dn.t[j],"dn",j);
					Image((*cum),"cum debut",0);
					Image(allsteps,"allsteps debut",0);
					EE.Enl();
				   }
				   istored=0;
				   break;
			   }
			} 
			if(istored) { 
				USHORT ii = tstore.AddMul(istored, istoref);
				tsets[i] =- tcandgo.itt;
				elims.Set(i); 
				tcandgo.tt[tcandgo.itt++].Add(ii, chain4_bf, tot_count);  
				if(0){					
					EE.Enl("multi created");
					tstore.Print(this,&EE,tcandgo.tt[-tsets[i]].index);
				}
			}			
		} 
	}
}
void PUZZLE :: NestedMultiLevel4 ( BFTAG & elims ) { if ( 0 ) { EE . E ( " " ) ; EE . Enl ( npas ) ; Image ( ( * cum ) , " " , 0 ) ; Image ( allsteps , " " , 0 ) ; } for ( int ie = 1 ; ie < zcx . izc ; ie ++ ) { const SET & chx = zcx . zc [ ie ] ; int nni = chx . ncd , aig2 = 0 ; BFTAG zt ; zt . SetAll_1 ( ) ; zt = zt . FalseState ( ) ; zt -= ( * cum ) ; if ( chx . type - SET_base ) continue ; for ( int i = 0 ; i < nni ; i ++ ) { USHORT cd = chx . tcd [ i ] , j = cd << 1 ; if ( cum -> On ( j ) ) { aig2 = 1 ; break ; } if ( dn . t [ j ] . On ( j ^ 1 ) ) { aig2 = 1 ; break ; } zt . Clear ( j ^ 1 ) ; if ( cum -> Off ( j ^ 1 ) ) { zt &= dn . t [ j ] ; zt -= dn . t [ j ] . Inverse ( ) ; } } if ( aig2 || zt . IsEmpty ( ) ) continue ; if ( 0 ) { EE . E ( " " ) ; chx . Image ( this , & EE ) ; Image ( zt , " " , 0 ) ; EE . Enl ( ) ; } USHORT wtt [ 400 ] , iwtt ; zt . String ( wtt , iwtt ) ; for ( int ii = 0 ; ii < iwtt ; ii ++ ) { int i = wtt [ ii ] ; if ( tsets [ i ] ) continue ; if ( 0 ) { EE . E ( " " ) ; chx . Image ( this , & EE ) ; EE . E ( " " ) ; zpln . ImageTag ( i ) ; EE . Enl ( ) ; } chain4_bf . SetAll_0 ( ) ; USHORT istored = 0 , istoref = 0 , tot_count = 0 ; for ( int i2 = 0 ; i2 < nni ; i2 ++ ) { USHORT cd = chx . tcd [ i2 ] , j = cd << 1 ; if ( cum -> On ( j ^ 1 ) ) { chain4_bf . Set ( j ^ 1 ) ; continue ; } int ii = 2 ; if ( dpn . t [ j ] . On ( i ) ) { chain4_iresult = 2 ; chain4_result [ 0 ] = j ; chain4_result [ 1 ] = i ; back4_bfsource . SetAll_0 ( ) ; } else ii = CaseNestedLevel4 ( j , i ) ; if ( ii ) { chain4_bf |= back4_bfsource ; if ( 0 ) { EE . E ( " " ) ; zpln . ImageTag ( j ) ; EE . Esp ( ) ; zpln . ImageTag ( i ) ; EE . Enl ( ) ; zpln . PrintImply ( chain4_result , chain4_iresult ) ; } istoref = tstore . AddChain ( chain4_result , chain4_iresult ) ; if ( ! istored ) istored = istoref ; tot_count += chain4_iresult ; } else { if ( 0 ) { EE . E ( " \n \n " ) ; zpln . ImageTag ( j ) ; EE . Esp ( ) ; zpln . ImageTag ( i ) ; chx . Image ( this , & EE ) ; EE . Enl ( ) ; Image ( dpn . t [ j ] , " " , j ) ; Image ( dn . t [ j ] , " " , j ) ; Image ( ( * cum ) , " " , 0 ) ; Image ( allsteps , " " , 0 ) ; EE . Enl ( ) ; } istored = 0 ; break ; } } if ( istored ) { USHORT ii = tstore . AddMul ( istored , istoref ) ; tsets [ i ] = - tcandgo . itt ; elims . Set ( i ) ; tcandgo . tt [ tcandgo . itt ++ ] . Add ( ii , chain4_bf , tot_count ) ; if ( 0 ) { EE . Enl ( " " ) ; tstore . Print ( this , & EE , tcandgo . tt [ - tsets [ i ] ] . index ) ; } } } } }
Now looking for multi chains eliminations if any
the bfs must contain all candidates killed by the main assumption
and the source of all new strong links used
Now looking for multi chains eliminations if any the bfs must contain all candidates killed by the main assumption and the source of all new strong links used
// dn.Image(); // candidate in tag form // set assigned // don't do if one candidate cleared through forcing chain // set assigned // set not in the target 			  // don't do if x -> a true  // if ok second round for action	 // don't do if already found // candidate in tag form // already false // make it simple if direct // should always be	 //end if // stop that case, means faced a contradiction chain // debugging sequence // end i2  //should always be unless contr chain seen // end tag i // end ie