Example #1
0
        //====================================================================================
        public void SDK_ProblemMakerReal(CancellationToken ct)    //Creating problems[Automatic]
        {
            try{
                int mlt = MltProblem;
                pGNPX_Eng.Set_MethodLst_Run();

                do
                {
                    if (ct.IsCancellationRequested)
                    {
                        ct.ThrowIfCancellationRequested(); return;
                    }

                    LoopCC++; TLoopCC++;
                    List <UCell> BDL = GeneratePuzzleCandidate( );   //Problem candidate generation
                    UPuzzle      P   = new UPuzzle(BDL);
                    pGNPX_Eng.SetGP(P);

                    pGNPX_Eng.AnalyzerCounterReset();
                    pGNPX_Eng.sudokAnalyzerAuto(ct);

                    if (GNPZ_Engin.retCode == 0)
                    {
#if DEBUG
                        __ret000 = true;  //##########
#endif
                        string prbMessage;
                        int    DifLevel = pGNPX_Eng.GetDifficultyLevel(out prbMessage);
                        if (DifLevel < lvlLow || lvlHgh < DifLevel)
                        {
                            continue;                                      //Difficulty check
                        }
#if DEBUG
                        __ret001 = true;  //##########
#endif
                        P.DifLevel   = DifLevel;
                        P.Name       = prbMessage;
                        P.TimeStamp  = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                        P.solMessage = pGNPX_Eng.DGViewMethodCounterToString();
                        pGNP00.SDK_ProblemListSet(P);

                        SDKEventArgs se = new SDKEventArgs(ProgressPer: (--mlt));
                        Send_Progress(this, se);  //(can send information in the same way as LoopCC.)
                        if (CbxNextLSpattern)
                        {
                            rxCTRL = 0;                //Change LS pattern at next problem generation
                        }
                    }
                }while(mlt > 0);
            }
            catch (TaskCanceledException) { WriteLine("...Canceled by user."); }
            catch (Exception ex) { WriteLine(ex.Message + "\r" + ex.StackTrace); }
        }