SEclone  general class for command and rating handling

 

The corresponding file in the program is

 

 #include "h\_01y_  opsudo.h"             // storing and managing options

 

 

OPSUDO, handling the command line filters and managing ER EP ED

 

That class has only one member  “o$”.

Up to now, data to store are not so far from final, but most of the code has still to be written.

 

That class is very important in all filtering  services offered by the program.

It is also the place where the final print is called

 

 

Here above is the present status

 

I have doubts about the use of option “split” which is now implicit.

   If not filtered go to output 1

   If filtered got ot output 2

Internal ER EP ED are integer 9.8 -> 98

 

Errors are identified by ER=EP=0 and ED= error code in the print (output 2)

Filtered puzzles should have  ER<10 (1.0) to make the difference with an error

 

// class storing, managing  and testing options of the command line

// also giving at each step the status towards the parameters of the command line

// and storing max er;ep;ed

 

// -d   stop if not ED also --diamond

// -p   stop if not EP also --pearl

// -d>  stop if ed lower than    -d>xx.y

// -p<  stop if ED higher than   -d<xx.y

// -p>  stop if ep lower than    -p>xx.y

// -d<  stop if Ep higher than   -p<xx.y

// -r<  stop if ED higher than   -r<xx.y

//      can have all < >

// -t   allow printing of the solution (test mode)

// -(.)>  stop if after n cycles if highest rating still lower than -(n)>xx.y

// -e  elapsed time per puzzle (and total for benchmark)

//                   options processed outside that class

// -i input file also --input=

// -s split treatment only if d> or d< (or both) is defined

class OPSUDO

{public:

 int o1,   //main mode 0 basic, 1 ed, 2 ep ,3  (n)x.y

        ot,   //option test on

        os,   //option split on

        maxed,      // ed limit for ED filter <

        mined,      // ed limit for ed filter >

        maxep,      // ep limit for EP filter <

        minep,      // ep limit for EP filter >

        maxer,      // er limit for -r<     (rate only lowest puzzles

        miner,      // er limit for -n(?)> (high rating low ed)

        edcycles,   // number of cycles for differed ed

      ptime,      // write time after er ep ed

        ir,          // return code for Step()

        cycle,            // counting cycles in the main loop

        assigned,  // counting assigned in the main loop

        ermax,     // final er if ok or cancelled due to filters

        epmax,     // final ep if ok or cancelled due to filters

        edmax,     // final ed if ok or cancelled due to filters

        difficulty;  // storing last call for difficulty used to set er ep ed

 

 OPSUDO()  // constructor, overall initial values

     {o1=ot=0;edcycles=1;

      mined=minep=miner=0;maxed=maxep=maxer=200;

         ptime=0;

     } 

 

void Init() // start of a resolution

       {cycle=assigned=edcycles=0;

           ermax=epmax=edmax=0;

         }

// filter on ED

int is_ed_ep()  ; // at the start of a new cycle

 

void Step(SolvingTechnique dif)  ;  // analyse what to do at that level

 

void SetDif(USHORT dif){difficulty=dif;} // sub level inside a process

void SetEr()   // something found at the last difficulty level

      {if((cycle==1)&& difficulty>edmax) edmax=difficulty;

       if(((!assigned)|| (!epmax))&& difficulty>epmax) epmax=difficulty;

       if(difficulty>ermax) ermax=difficulty;      }

void Seterr(int x)  // an error condition has been found

      {ermax=0; epmax=0;edmax=x;}

 

void PrintErEpEd()

     {if(aigstop)ermax=0;

      if((ermax<10) || (ermax>120))se_refus.PrintErEpEd(ermax,epmax,edmax);

         else  foutput.PrintErEpEd(ermax,epmax,edmax);}

 

int  pctl()  // contrôle print on console for test purpose

{cout << "summary of parsing"<<endl;

 if(o1==1) cout << "mode ed"<<endl;

 if(o1==2) cout << "mode ep"<<endl;

 if(o1==3) cout << "special filters on"<<endl;

 if(ot) cout << "test option"<<endl;

 if(maxed<200)cout << "ed<"<<maxed<<endl;

 if(mined)cout << "ed>"<<mined<<endl;

 if(maxep<200)cout << "ep<"<<maxep<<endl;

 if(minep)cout << "ep>"<<minep<<endl;

 if(maxer<200)cout << "er<"<<maxer<<endl;

 if(miner)cout << "differred ed cycl="<<edcycles<<" rating"<<miner<<endl;

 if(ptime) cout << "print time"<<endl;

 if(maxed<mined || maxep<minep || maxer<miner)

 {cout << "cancelled due to contradiction in filters"<<endl;

 return 1;}

return 0;}

 }o$;

 

 

 

// filter at the start of a new cycle

 

int OPSUDO::is_ed_ep()  // is the ed or  condition fullfilled

{switch(o1)

  {case 0: return 0;       // nothing to do

     // if -d command, other filters ignored 

   case 1: if(cycle<2) return 0;      // -d command

              if(ermax> edmax)  {ermax=0;epmax=0;return 1;}  // not diamond

                 return 0;// continue if still ed

     // if -p command, similar results

   case 2: if(!assigned) return 0;   // -p command

              if(ermax> epmax) {ermax=0;return 1;} // not pearl

              return 0;// continue if still ep

  }   

      

// now, we have no -d no -p command but at least one filter is on

// give priority to the (n) command

if(edcycles && cycle>edcycles)    // -(n) command

                     if(ermax >= miner) {ermax=0;return 1;} // finished

//then all max conditions

if(edmax>maxed || epmax>maxep || ermax>maxer)

            {ermax=20;return 1;} // finished

// and finally min ED and min EP

if(cycle>1 && edmax<mined)  {ermax=0;return 1;} // finished

if(assigned && epmax<minep)  {ermax=0;return 1;} // finished

return 0;}

 

// the next routine is called at each step of the process

// the searched rating is stored in "difficulty"

// a check of filters is made and if any special filter is active,

// the process is cancelled

// return code 0 nothing special

//             1 process cancelled

//             2 ignore (er<x.y) these routines

 

void OPSUDO::Step(SolvingTechnique dif)    // analyse what to do at that level

{//E$.E("step=");E$.Enl(dif );

ir=0;difficulty=dif;  

if(o1<2) return; //nothing to do for -d command

// if -p command, stop if we pass maxep

if(o1==2)

       if(assigned && difficulty>maxep)

          {maxer=0;ir=1;return;}

       else return;

 

// now  other special filters

// (n)  active if we pass the limit

if(edcycles && cycle>edcycles)    // -(n) command

       if(difficulty >= miner) {maxer=0;ir=1;return;}  // finished

 

if(difficulty>maxer) {ir=2;return;} // filter on maxer cancelling high rating

 

if(difficulty>maxed || difficulty>maxep ){maxer=0; ir=1;return;}

 

}