src/puzzle.cpp
/* while cycle  for GoNested first run, just find potential
   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 run, just find potential
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 run just find potential 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::GoNestedWhileShort(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, toff[10]; 
		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(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(opp && aig2) {
					EE.E("set derive actif ");
					chx.Image(this,&EE);
					EE.Enl();}
			}
			break;
		case SET_set: 
			for(int i = 0; i < (nni - 1); i++) {  
				if(cum->On(1 + 2 * chx.tcd[i]))
					continue;
				n = 1;
				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(opp && aig2) {
				EE.E("set actif event");
				chx.Image(this,&EE);
				ev.Image(this,&EE);
			}
			break;	
		} 
	}
	if(nested_aig)
		return;
	Gen_dpnShort(tag);
	BFTAG elims; 
	NestedForcingShort(elims); 
	if(elims.substract(allsteps)) { 
		if(opp)
			Image(elims,"forcing chain elims" ,0);	
		allsteps |= elims; 
		nested_aig = 1;
	}
	if(rbase < 100)
		return;
	BFTAG elims2; 
	NestedMultiShort(elims2); 
	if(opp && options.ot)
		Image(elims2,"multiforcing recap short ", 0);
	if(elims2.IsNotEmpty()) {
		allsteps |= elims2; 
		nested_aig=1;
	}
}
void PUZZLE :: GoNestedWhileShort ( 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 , toff [ 10 ] ; 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 ( 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 ( opp && aig2 ) { EE . E ( " " ) ; chx . Image ( this , & EE ) ; EE . Enl ( ) ; } } break ; case SET_set : for ( int i = 0 ; i < ( nni - 1 ) ; i ++ ) { if ( cum -> On ( 1 + 2 * chx . tcd [ i ] ) ) continue ; n = 1 ; 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 ( opp && aig2 ) { EE . E ( " " ) ; chx . Image ( this , & EE ) ; ev . Image ( this , & EE ) ; } break ; } } if ( nested_aig ) return ; Gen_dpnShort ( tag ) ; BFTAG elims ; NestedForcingShort ( elims ) ; if ( elims . substract ( allsteps ) ) { if ( opp ) Image ( elims , " " , 0 ) ; allsteps |= elims ; nested_aig = 1 ; } if ( rbase < 100 ) return ; BFTAG elims2 ; NestedMultiShort ( elims2 ) ; if ( opp && options . ot ) Image ( elims2 , " " , 0 ) ; if ( elims2 . IsNotEmpty ( ) ) { allsteps |= elims2 ; nested_aig = 1 ; } }
while cycle  for GoNested first run, just find potential
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 run just find potential 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
//const BFTAG &cum_here = *cum; // to receive new strong links // look first for direct  // and in the total  // check now sets // 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 // must force new loop // nothing valid switch to a contradiction on any candidate // if ok second round for action	 // candidate in tag form // kep only the first one // in a set all components must be on // must all be there // false state on // end switch // end proc // we look for indirect hints // zcf.h_one.dp.Image();dpn.Image(); // force false so use elims.inverse() // and in the total  //   in the total 