src/puzzle.cpp
/* while cycle  for GoNested 
   first apply new actions from direct implications and sets
   then check if new strong links appeared
   if new strong links, search for new indirect forcing chain
   if level, check anyway new multi chain eliminations 
*/
while cycle  for GoNested
first apply new actions from direct implications and sets
then check if new strong links appeared
if new strong links, search for new indirect forcing chain
if level, check anyway new multi chain eliminations
while cycle for GoNested first apply new actions from direct implications and sets then check if new strong links appeared if new strong links search for new indirect forcing chain if level check anyway new multi chain eliminations
void PUZZLE::GoNestedWhile(USHORT tag) {
	USHORT aignl = 1;
	BFTAG  * hdpb = hdp_base_nested.t; 
	for(int it = 0; it < ita; it++) {
		BFTAG x = to[ta[it]];
		if(x.substract(allsteps)) {
			if(opp)
				Image(x,"applied std", ta[it]);
			allsteps |= x; 
			nested_aig=1;
		} 
	}
	for(int ie = 1; ie < zcx.izc; ie++) {
		const SET &chx = zcx.zc[ie];
		int n = 0, nni = chx.ncd, aig2 = 0;
		int toff[3] = {0,0,0};
		switch (chx.type) {
		case SET_base:  
			{
				BFTAG bfw;
				for(int i = 0; i < nni; i++) { 
					USHORT cd = chx.tcd[i], j = cd << 1; 
					if(cum->On(j)) {
						n = 3;
						break;
					}
					if(cum->Off(j ^ 1)) {
						toff[n++] = j;
						if(n > 2)
							break;
					} 
					else
						bfw.Set(j ^ 1);
				}
				USHORT cd1 = toff[0], cd2 = toff[1];
				if(n == 2) {    
                  if(rbase>90){  
					if(hdpb[cd1].Off(cd2 ^ 1) || 
					   hdpb[cd2].Off(cd1 ^ 1) || 
					   hdpb[cd1 ^ 1].Off(cd2) || 
					   hdpb[cd2 ^ 1].Off(cd1)) {
						hdpb[cd1].Set(cd2 ^ 1);
						hdpb[cd2].Set(cd1 ^ 1);
						hdpb[cd1 ^ 1].Set(cd2);
						hdpb[cd2 ^ 1].Set(cd1);
						aignl = 0;
						tcandgo.AddStrong(cd1 >> 1, cd2 >> 1, bfw, nni - 2);
                        nested_aig=1;
					}
				  }
					break;
				}
				if(!n){  
                    for(int i = 0; i < nni; i++) { 
                         USHORT cd = chx.tcd[i], j = cd << 1;
						 if(allsteps.Off(j)) {
						      allsteps.Set(j);
						      tsets[j] = ie;
					          nested_aig = 1;
						      aig2 = 1;
						 }
					}
					break;
				}
				if(n - 1)
					break;	
				USHORT j = toff[0]; 
				if(allsteps.Off(j)) {
						allsteps.Set(j);
						tsets[j] = ie;
						nested_aig = 1;
						aig2 = 1;
					}
				if(0 && aig2) {
					EE.E("set derive actif ");
					chx.Image(this,&EE);
					EE.E("  valid ");
					zpln.ImageTag(j);
					EE.Enl();
				}
			}
			break;
		case SET_set : 
			if(rbase<80) break; 
			for(int i = 0; i < (nni - 1); i++) {
				if(cum->Off((chx.tcd[i] << 1) ^ 1)) {
					n++;
					if(n)
						break;
				}
			}
			if(n)
				break; 
			const EVENT ev = tevent.t[chx.tcd[nni - 1] - event_vi];
			const EVENTLOT &evl = ev.evl;
			for(int i = 0; i < evl.itcd; i++) {
				int j = (evl.tcd[i] << 1) ^ 1; 
				if(allsteps.On(j))
					continue;
				allsteps.Set(j);
				tsets[j] = ie;
				nested_aig = 1;
				aig2 = 1;       
			}
			if(0 && aig2) {
				EE.E("set actif event");
				chx.Image(this,&EE);
				ev.Image(this,&EE);
			}
			break;	
		} 
	}
	if((rbase<95) || nested_aig)
		return;    
	Gen_dpn(tag);    
	BFTAG elims; 
	if(rbase<105)
		NestedForcing(elims); 
	else
	    NestedForcingLevel4(elims); 
	if(opp && options.ot) {
		Image(allsteps,"allsteps", 0);
		Image(elims,"netforcing recap", 0);
	}
	if(!(rbase < 100 || elims.Count() > 20) ){
		BFTAG elims2; 
		if(rbase < 105)
			NestedMulti(elims2); 
		else
			NestedMultiLevel4(elims2); 
		if(opp && options.ot)
			Image(elims2,"multiforcing recap", 0);
		if(elims2.IsNotEmpty()) {
			allsteps |= elims2; 
			nested_aig=1;
		}   
	}
	if(elims.IsNotEmpty()) {
		allsteps |= elims; 
		nested_aig = 1;
	}
}
void PUZZLE :: GoNestedWhile ( USHORT tag ) { USHORT aignl = 1 ; BFTAG * hdpb = hdp_base_nested . t ; for ( int it = 0 ; it < ita ; it ++ ) { BFTAG x = to [ ta [ it ] ] ; if ( x . substract ( allsteps ) ) { if ( opp ) Image ( x , " " , ta [ it ] ) ; allsteps |= x ; nested_aig = 1 ; } } for ( int ie = 1 ; ie < zcx . izc ; ie ++ ) { const SET & chx = zcx . zc [ ie ] ; int n = 0 , nni = chx . ncd , aig2 = 0 ; int toff [ 3 ] = { 0 , 0 , 0 } ; switch ( chx . type ) { case SET_base : { BFTAG bfw ; for ( int i = 0 ; i < nni ; i ++ ) { USHORT cd = chx . tcd [ i ] , j = cd << 1 ; if ( cum -> On ( j ) ) { n = 3 ; break ; } if ( cum -> Off ( j ^ 1 ) ) { toff [ n ++ ] = j ; if ( n > 2 ) break ; } else bfw . Set ( j ^ 1 ) ; } USHORT cd1 = toff [ 0 ] , cd2 = toff [ 1 ] ; if ( n == 2 ) { if ( rbase > 90 ) { if ( hdpb [ cd1 ] . Off ( cd2 ^ 1 ) || hdpb [ cd2 ] . Off ( cd1 ^ 1 ) || hdpb [ cd1 ^ 1 ] . Off ( cd2 ) || hdpb [ cd2 ^ 1 ] . Off ( cd1 ) ) { hdpb [ cd1 ] . Set ( cd2 ^ 1 ) ; hdpb [ cd2 ] . Set ( cd1 ^ 1 ) ; hdpb [ cd1 ^ 1 ] . Set ( cd2 ) ; hdpb [ cd2 ^ 1 ] . Set ( cd1 ) ; aignl = 0 ; tcandgo . AddStrong ( cd1 >> 1 , cd2 >> 1 , bfw , nni - 2 ) ; nested_aig = 1 ; } } break ; } if ( ! n ) { for ( int i = 0 ; i < nni ; i ++ ) { USHORT cd = chx . tcd [ i ] , j = cd << 1 ; if ( allsteps . Off ( j ) ) { allsteps . Set ( j ) ; tsets [ j ] = ie ; nested_aig = 1 ; aig2 = 1 ; } } break ; } if ( n - 1 ) break ; USHORT j = toff [ 0 ] ; if ( allsteps . Off ( j ) ) { allsteps . Set ( j ) ; tsets [ j ] = ie ; nested_aig = 1 ; aig2 = 1 ; } if ( 0 && aig2 ) { EE . E ( " " ) ; chx . Image ( this , & EE ) ; EE . E ( " " ) ; zpln . ImageTag ( j ) ; EE . Enl ( ) ; } } break ; case SET_set : if ( rbase < 80 ) break ; for ( int i = 0 ; i < ( nni - 1 ) ; i ++ ) { if ( cum -> Off ( ( chx . tcd [ i ] << 1 ) ^ 1 ) ) { n ++ ; if ( n ) break ; } } if ( n ) break ; const EVENT ev = tevent . t [ chx . tcd [ nni - 1 ] - event_vi ] ; const EVENTLOT & evl = ev . evl ; for ( int i = 0 ; i < evl . itcd ; i ++ ) { int j = ( evl . tcd [ i ] << 1 ) ^ 1 ; if ( allsteps . On ( j ) ) continue ; allsteps . Set ( j ) ; tsets [ j ] = ie ; nested_aig = 1 ; aig2 = 1 ; } if ( 0 && aig2 ) { EE . E ( " " ) ; chx . Image ( this , & EE ) ; ev . Image ( this , & EE ) ; } break ; } } if ( ( rbase < 95 ) || nested_aig ) return ; Gen_dpn ( tag ) ; BFTAG elims ; if ( rbase < 105 ) NestedForcing ( elims ) ; else NestedForcingLevel4 ( elims ) ; if ( opp && options . ot ) { Image ( allsteps , " " , 0 ) ; Image ( elims , " " , 0 ) ; } if ( ! ( rbase < 100 || elims . Count ( ) > 20 ) ) { BFTAG elims2 ; if ( rbase < 105 ) NestedMulti ( elims2 ) ; else NestedMultiLevel4 ( elims2 ) ; if ( opp && options . ot ) Image ( elims2 , " " , 0 ) ; if ( elims2 . IsNotEmpty ( ) ) { allsteps |= elims2 ; nested_aig = 1 ; } } if ( elims . IsNotEmpty ( ) ) { allsteps |= elims ; nested_aig = 1 ; } }
while cycle  for GoNested
first apply new actions from direct implications and sets
then check if new strong links appeared
if new strong links, search for new indirect forcing chain
if level, check anyway new multi chain eliminations
while cycle for GoNested first apply new actions from direct implications and sets then check if new strong links appeared if new strong links search for new indirect forcing chain if level check anyway new multi chain eliminations
// to receive new strong links // look first for direct  // and in the total  // check now sets //int toff[10]; // must be n-1 false or n false (then all is ok) // check if active 0 to 2 cand unknown // max one free  // candidate in tag form // set assigned // this is a new strong link // only for nested // force new loop if new strong link // nothing valid switch to a contradiction on any candidate // if ok second round for action	 // candidate in tag form // in a set all components must be on // not for Nishio // must all be there // false state on // end switch // end proc // stop if not nested mode or something found // we look for indirect hints // create a fresh reduced set of tags  // zcf.h_one.dp.Image();dpn.Image(); //don't do eliminations now, it creates troubble later // limit 20 is realism   //  in the total  // and in the total  //		to study that puzzle generating a huge elims // 1....67...571.......9....1..4....3.......8..29..7...6......24..5..6...9.....3...8;11.40;10.70;10.00