src/puzzle.cpp
void PUZZLE::NestedMulti(BFTAG & elims) {
	for(int ie = 1; ie < zcx.izc; ie++) {
		const SET &chx = zcx.zc[ie];
		int nni = chx.ncd, aig2 = 0; 
		BFTAG zt(BFTAG::InitFalseState);

		BFTAG ttt = allsteps;
		ttt |= elims;
		zt -= ttt;
		if(chx.type - SET_base)
			continue;
		// must be  n false 
		for(int i = 0; i < nni; i++) { // max one free 
			USHORT cd = chx.tcd[i], j = cd << 1; // candidate in tag form
			zt.Clear(j^1);    // don't keep eliminations if belonging to the set
			if(cum->On(j)) {
				aig2 = 1;
				break;
			}// set assigned
			if(cum->Off(j ^ 1))
				zt &= dn.t[j];
		}
		if(aig2 )
			continue;	// if ok second round for action	

		USHORT p[640],np;
		zt.String(p,np);
		for(int ip = 0; ip < np; ip++) {
			int i=p[ip];
			BFTAG bfs;
			USHORT istored = 0, istoref = 0, tot_count = 0;
			int era=0; // one error somewhere debugging data
			for(int i2=0;i2<nni;i2++) {
				USHORT cd = chx.tcd[i2], j = cd << 1; // candidate in tag form
				if(cum->On(j ^ 1)) {
					bfs.Set(j ^ 1);
					continue;
				}// already false
				if(allsteps.On(j^1)){ // this creates a problem, stop the process
					era=2;
					break;
				}
				// here can be direct and this is not done in search chain
				// dummy cycle if direct to have common process

				BFTAG wch = dpn.t[j]; 
				USHORT tt[50], itt = 2; tt[0] = j; tt[1] = i;
				if(wch.Off(i)) {

					int erb=0,  // to catch an error in that sequence
					npasch = wch.SearchChain(dpn.t, j, i);	
					if((!npasch) || (npasch > 40))
						erb=3;// ignore long chains 1+npasch;  //  debug later if 0

					else{

						itt = npasch + 2; 
					  if(wch.TrackBack(dpn.t, j, i, tt, itt, i)) 
						  erb=2;// intercept error for debugging
					}

					if(erb) { // add some debugging code
						if(erb<3){
							EE.E("nested multi erb="); EE.E(erb);
							EE.E(" npasch="); EE.E(npasch);EE.Esp();
							chx.Image(this,&EE);
							EE.E( " search "); zpln.ImageTag(j); EE.Esp();
							EE.E( " => "); zpln.ImageTag(i); EE.Enl();
							Image((*cum),"cum ",0);
							Image(dpn.t[j],"dpn (j)",0);
							Image(dn.t[j],"dn (j)",0);
							EE.Enl();
							era=1;
						}
						else era=3;
					}

					else {
				
				    // must add the source for the new strong links
				    for(int j = 1; j < itt - 1; j++) { // all strong links 
					   if((!(tt[j]&1)) || (tt[j+1]&1))
						   continue;
					   const CANDGOSTRONG * w = tcandgo.Get(tt[j], tt[j+1]);
					   if(w) bfs |= w->source;// it is a new strong link		
				    }
				    istoref = tstore.AddChain(tt, itt);
				    if(!istored)
					   istored = istoref;
				   tot_count += itt;

			       }// end else not erb
				}  //end if
			} // end i2

            if(era){ 
				if(era>1)
					continue; // process stopped after candidate killed in forcing chains
				
				// stop and log message to see
 			  stop_rating=1;
			  elims.SetAll_0();
			  return;
			}

			 // here a case to be investigated deeper
			 //.2..5......71....668.......2..7....8..8...3....1..4.9..1.2....7....9.4.......3.5. ED=0.0/0.0/0.5
			 // no error in detailed chains
			 // but nothing stored, so all was defined ???
			 // good example to check the process

			if(istored) { //should always be
				USHORT ii = tstore.AddMul(istored, istoref);
				tsets[i] =- tcandgo.itt;
				elims.Set(i); 
				tcandgo.tt[tcandgo.itt++].Add(ii, bfs, tot_count); 

                if(opp)  // print it it test mode
	             {EE.E("new eliminated");   zpln.ImageTag(i); 
		          EE.E("  ichain="); EE.E(tstore.ise); 
		          EE.E("  stored as "); EE.Enl(tsets[i]); 
                 }
			}
		} // end tag i
	}// end ie
}
/*
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
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
void PUZZLE::NestedMulti(BFTAG & elims) {
	for(int ie = 1; ie < zcx.izc; ie++) {
		const SET &chx = zcx.zc[ie];
		int nni = chx.ncd, aig2 = 0; 
		BFTAG zt(BFTAG::InitFalseState);
		BFTAG ttt = allsteps;
		ttt |= elims;
		zt -= ttt;
		if(chx.type - SET_base)
			continue;
		for(int i = 0; i < nni; i++) { 
			USHORT cd = chx.tcd[i], j = cd << 1; 
			zt.Clear(j^1);    
			if(cum->On(j)) {
				aig2 = 1;
				break;
			}
			if(cum->Off(j ^ 1))
				zt &= dn.t[j];
		}
		if(aig2 )
			continue;	
		USHORT p[640],np;
		zt.String(p,np);
		for(int ip = 0; ip < np; ip++) {
			int i=p[ip];
			BFTAG bfs;
			USHORT istored = 0, istoref = 0, tot_count = 0;
			int era=0; 
			for(int i2=0;i2<nni;i2++) {
				USHORT cd = chx.tcd[i2], j = cd << 1; 
				if(cum->On(j ^ 1)) {
					bfs.Set(j ^ 1);
					continue;
				}
				if(allsteps.On(j^1)){ 
					era=2;
					break;
				}
				BFTAG wch = dpn.t[j]; 
				USHORT tt[50], itt = 2; tt[0] = j; tt[1] = i;
				if(wch.Off(i)) {
					int erb=0,  
					npasch = wch.SearchChain(dpn.t, j, i);	
					if((!npasch) || (npasch > 40))
						erb=3;
					else{
						itt = npasch + 2; 
					  if(wch.TrackBack(dpn.t, j, i, tt, itt, i)) 
						  erb=2;
					}
					if(erb) { 
						if(erb<3){
							EE.E("nested multi erb="); EE.E(erb);
							EE.E(" npasch="); EE.E(npasch);EE.Esp();
							chx.Image(this,&EE);
							EE.E( " search "); zpln.ImageTag(j); EE.Esp();
							EE.E( " => "); zpln.ImageTag(i); EE.Enl();
							Image((*cum),"cum ",0);
							Image(dpn.t[j],"dpn (j)",0);
							Image(dn.t[j],"dn (j)",0);
							EE.Enl();
							era=1;
						}
						else era=3;
					}
					else {
				    for(int j = 1; j < itt - 1; j++) { 
					   if((!(tt[j]&1)) || (tt[j+1]&1))
						   continue;
					   const CANDGOSTRONG * w = tcandgo.Get(tt[j], tt[j+1]);
					   if(w) bfs |= w->source;
				    }
				    istoref = tstore.AddChain(tt, itt);
				    if(!istored)
					   istored = istoref;
				   tot_count += itt;
			       }
				}  
			} 
            if(era){ 
				if(era>1)
					continue; 
 			  stop_rating=1;
			  elims.SetAll_0();
			  return;
			}
			if(istored) { 
				USHORT ii = tstore.AddMul(istored, istoref);
				tsets[i] =- tcandgo.itt;
				elims.Set(i); 
				tcandgo.tt[tcandgo.itt++].Add(ii, bfs, tot_count); 
                if(opp)  
	             {EE.E("new eliminated");   zpln.ImageTag(i); 
		          EE.E("  ichain="); EE.E(tstore.ise); 
		          EE.E("  stored as "); EE.Enl(tsets[i]); 
                 }
			}
		} 
	}
}
void PUZZLE :: NestedMulti ( BFTAG & elims ) { for ( int ie = 1 ; ie < zcx . izc ; ie ++ ) { const SET & chx = zcx . zc [ ie ] ; int nni = chx . ncd , aig2 = 0 ; BFTAG zt ( BFTAG :: InitFalseState ) ; BFTAG ttt = allsteps ; ttt |= elims ; zt -= ttt ; if ( chx . type - SET_base ) continue ; for ( int i = 0 ; i < nni ; i ++ ) { USHORT cd = chx . tcd [ i ] , j = cd << 1 ; zt . Clear ( j ^ 1 ) ; if ( cum -> On ( j ) ) { aig2 = 1 ; break ; } if ( cum -> Off ( j ^ 1 ) ) zt &= dn . t [ j ] ; } if ( aig2 ) continue ; USHORT p [ 640 ] , np ; zt . String ( p , np ) ; for ( int ip = 0 ; ip < np ; ip ++ ) { int i = p [ ip ] ; BFTAG bfs ; USHORT istored = 0 , istoref = 0 , tot_count = 0 ; int era = 0 ; for ( int i2 = 0 ; i2 < nni ; i2 ++ ) { USHORT cd = chx . tcd [ i2 ] , j = cd << 1 ; if ( cum -> On ( j ^ 1 ) ) { bfs . Set ( j ^ 1 ) ; continue ; } if ( allsteps . On ( j ^ 1 ) ) { era = 2 ; break ; } BFTAG wch = dpn . t [ j ] ; USHORT tt [ 50 ] , itt = 2 ; tt [ 0 ] = j ; tt [ 1 ] = i ; if ( wch . Off ( i ) ) { int erb = 0 , npasch = wch . SearchChain ( dpn . t , j , i ) ; if ( ( ! npasch ) || ( npasch > 40 ) ) erb = 3 ; else { itt = npasch + 2 ; if ( wch . TrackBack ( dpn . t , j , i , tt , itt , i ) ) erb = 2 ; } if ( erb ) { if ( erb < 3 ) { EE . E ( " " ) ; EE . E ( erb ) ; EE . E ( " " ) ; EE . E ( npasch ) ; EE . Esp ( ) ; chx . Image ( this , & EE ) ; EE . E ( " " ) ; zpln . ImageTag ( j ) ; EE . Esp ( ) ; EE . E ( " " ) ; zpln . ImageTag ( i ) ; EE . Enl ( ) ; Image ( ( * cum ) , " " , 0 ) ; Image ( dpn . t [ j ] , " " , 0 ) ; Image ( dn . t [ j ] , " " , 0 ) ; EE . Enl ( ) ; era = 1 ; } else era = 3 ; } else { for ( int j = 1 ; j < itt - 1 ; j ++ ) { if ( ( ! ( tt [ j ] & 1 ) ) || ( tt [ j + 1 ] & 1 ) ) continue ; const CANDGOSTRONG * w = tcandgo . Get ( tt [ j ] , tt [ j + 1 ] ) ; if ( w ) bfs |= w -> source ; } istoref = tstore . AddChain ( tt , itt ) ; if ( ! istored ) istored = istoref ; tot_count += itt ; } } } if ( era ) { if ( era > 1 ) continue ; stop_rating = 1 ; elims . SetAll_0 ( ) ; return ; } if ( istored ) { USHORT ii = tstore . AddMul ( istored , istoref ) ; tsets [ i ] = - tcandgo . itt ; elims . Set ( i ) ; tcandgo . tt [ tcandgo . itt ++ ] . Add ( ii , bfs , tot_count ) ; if ( opp ) { EE . E ( " " ) ; zpln . ImageTag ( i ) ; EE . E ( " " ) ; EE . E ( tstore . ise ) ; EE . E ( " " ) ; EE . Enl ( tsets [ i ] ) ; } } } } }
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
// must be  n false  // max one free  // candidate in tag form // don't keep eliminations if belonging to the set // set assigned // if ok second round for action	 // one error somewhere debugging data // candidate in tag form // already false // this creates a problem, stop the process // here can be direct and this is not done in search chain // dummy cycle if direct to have common process // to catch an error in that sequence // ignore long chains 1+npasch;  //  debug later if 0 // intercept error for debugging // add some debugging code // must add the source for the new strong links // all strong links  // it is a new strong link		 // end else not erb //end if // end i2 // process stopped after candidate killed in forcing chains // stop and log message to see // here a case to be investigated deeper //.2..5......71....668.......2..7....8..8...3....1..4.9..1.2....7....9.4.......3.5. ED=0.0/0.0/0.5 // no error in detailed chains // but nothing stored, so all was defined ??? // good example to check the process //should always be // print it it test mode // end tag i // end ie