private UPuzzle _SetScreenProblem( )
        {
            UPuzzle P = GNP00.GetCurrentProble( );

            _Display_GB_GBoard();
            if (P != null)
            {
                txtProbNo.Text          = (P.ID + 1).ToString();
                txtProbName.Text        = P.Name;
                nUDDifficultyLevel.Text = P.DifLevel.ToString();
                if (GNP00.pGP.pMethod != null)
                {
                    int DiffL = (GNP00.pGP.pMethod == null)? 0: GNP00.pGP.pMethod.DifLevel;
                    lblCurrentnDifficultyLevel.Content = $"Difficulty: {DiffL}"; //CurrentLevel
                    if (lblAnalyzerResult.Text != "")
                    {
                        lblCurrentnDifficultyLevel.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        lblCurrentnDifficultyLevel.Visibility = Visibility.Hidden;
                    }
                }
                btnProbPre.IsEnabled = (P.ID > 0);
                btnProbNxt.IsEnabled = (P.ID < GNP00.SDKProbLst.Count - 1);

                _Set_DGViewMethodCounter();
            }
            return(P);
        }
Exemplo n.º 2
0
        private void LstBxMltAns_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try{
                if (SDK_Ctrl.UGPMan == null)
                {
                    return;
                }
                var Q = (UProbS)LstBxMltAns.SelectedItem;
                if (Q == null)
                {
                    return;
                }
                selXUPP = Q.IDmp1 - 1;
                if (selXUPP < 0)
                {
                    return;
                }
                var U = UPP[selXUPP];
                lblAnalyzerResultM.Text = "[" + (Q.IDmp1) + "] " + Q.Sol_ResultLong;

                List <UPuzzle> pMltUProbLst = SDK_Ctrl.UGPMan.MltUProbLst;
                if (pMltUProbLst == null || pMltUProbLst.Count <= selXUPP)
                {
                    return;
                }
                UPuzzle pGPx = pMltUProbLst[selXUPP];
                SDK_Ctrl.UGPMan.pGPsel = pGPx;
                if (pGP.IDm != selXUPP)
                {
                    SDK_Ctrl.UGPMan.GPMnxt = null;
                }
                GNP00.GNPX_Eng.pGP = pGPx;
            }
            catch (Exception e2) { WriteLine($"{e2.Message}\r{e2.StackTrace}"); }
        }
        private void btnCopyProblem_Click(object sender, RoutedEventArgs e)
        {
            UPuzzle UPcpy = pGP.Copy(0, 0);

            UPcpy.Name = "copy";
            GNP00.CreateNewPrb(UPcpy); //reserve space for new problems
            _SetScreenProblem();       //Show free numbers
        }
        public void SDK_Save_ifNotContain()
        {
            UPuzzle pGP = GNPX_Eng.pGP;

            if (!Contain(pGP))
            {
                SDK_Save_EngGP();
            }
        }
        public UPuzzle GetCurrentProble( )
        {
            UPuzzle P = null;

            if (CurrentPrbNo >= 0 && CurrentPrbNo <= SDKProbLst.Count - 1)
            {
                P = SDKProbLst[CurrentPrbNo];
            }
            return(P);
        }
        public string SetSolution(UPuzzle GP, bool SolSet2, bool SolAll = false)
        {
            string solMessage = "";

            GNPX_Eng.pGP = GP;

            string prbMessage = "";

            if (SolAll || GNPX_Eng.pGP.DifLevel <= 0 || GNPX_Eng.pGP.Name == "")
            {
                foreach (var p in GP.BDL)
                {
                    if (p.No < 0)
                    {
                        p.No = 0;
                    }
                }

                GNPX_Eng.AnMan.Set_CellFreeB();
                GNPX_Eng.AnalyzerCounterReset();

                var tokSrc = new CancellationTokenSource();          //for suspension
                GNPX_Eng.sudokAnalyzerAuto(tokSrc.Token);

                if (GNPZ_Engin.retCode < 0)
                {
                    GNPX_Eng.pGP.DifLevel = -999;
                    GNPX_Eng.pGP.Name     = "unsolvable";
                }
                else
                {
                    if (GNPX_Eng.pGP.DifLevel <= 1 || GNPX_Eng.pGP.Name == "")
                    {
                        int difficult = GNPX_Eng.GetDifficultyLevel(out prbMessage);
                        if (GNPX_Eng.pGP.DifLevel <= 1)
                        {
                            GNPX_Eng.pGP.DifLevel = difficult;
                        }
                        if (GNPX_Eng.pGP.Name == "")
                        {
                            GNPX_Eng.pGP.Name = prbMessage;
                        }
                    }
                }
            }
            solMessage = "";    //prbMessage;
            if (SolSet2)
            {
                solMessage += GNPX_Eng.DGViewMethodCounterToString();
            }
                                                                              //適用手法を付加
                solMessage = solMessage.Trim();

            return(solMessage);
        }
 public void CreateNewPrb(UPuzzle UP = null)
 {
     if (UP == null)
     {
         UP = new UPuzzle("New Problem");
     }
     UP.ID = SDKProbLst.Count;
     GNPX_Eng.SetGP(UP);
     SDK_Save(UP);
     CurrentPrbNo = 999999999;
 }
Exemplo n.º 8
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); }
        }
        public void btnFavfileOutput(bool fType81 = true, bool SolSet = false, bool SolSet2 = false)
        {
            string LRecord;
            string fNameFav = "SDK_Favorite.txt";

            var tokSrc = new CancellationTokenSource(); //procedures for suspension

            GNPXApp000.SlvMtdCList[0] = true;           //use all methods

            UPuzzle pGP = GNPX_Eng.pGP;

            GNPX_Eng.AnMan.Set_CellFreeB();
            GNPX_Eng.sudokAnalyzerAuto(tokSrc.Token);
            string prbMessage;
            int    difLvl = GNPX_Eng.GetDifficultyLevel(out prbMessage);

            using (var fpW = new StreamWriter(fNameFav, true, Encoding.UTF8)){
                if (fType81)
                {
                    LRecord = "";
                    pGP.BDL.ForEach(q => { LRecord += Max(q.No, 0).ToString(); });
                    LRecord  = LRecord.Replace("0", ".");
                    LRecord += $" {(pGP.ID+1)} {pGP.DifLevel} \"{pGP.Name}\"";
                    if (SolSet && SolSet2)
                    {
                        LRecord += $" \"{SetSolution(pGP,SolSet2:true,SolAll:true)}\"";                //解を出力
                    }
                    if (pGP.TimeStamp != null)
                    {
                        LRecord += $" \"{pGP.TimeStamp}\"";
                    }
                }
                else
                {
                    LRecord = $"{pGP.ID+1}, {GNPX_Eng.pGP.DifLevel} \"{pGP.Name}\", \"{prbMessage}\"";
                    fpW.WriteLine(LRecord);

                    for (int r = 0; r < 9; r++)
                    {
                        int n = pGP.BDL[r * 9 + 0].No;
                        LRecord = n.ToString();
                        for (int c = 1; c < 9; c++)
                        {
                            n        = pGP.BDL[r * 9 + c].No;
                            LRecord += $", {n}";
                        }
                        LRecord += "\r";
                    }
                }
                fpW.WriteLine(LRecord);
            }
            GNPXApp000.SlvMtdCList[0] = false;//use selected methods
        }
        public void SDK_TransIX(int[] TrPara, bool TransB = false, bool DspSolB = false)
        {
            int rx = TrPara[8], cx = 1 - rx;

            for (int j = 0; j < 2; j++)
            {
                for (int k = 0; k < 9; k++)
                {
                    int n = RCX[j, k / 3 + 9];
                    RCX[j + 2, k] = RCX[j, n + k % 3];
                }
            }

            List <UCell> UCL = null;

            if (TransB)
            {
                UCL = new List <UCell>();
            }
            int [] AnsN2 = new int[81];
            int    r, c, w;

            for (int rc = 0; rc < 81; rc++)
            {
                r = RCX[rx + 2, rc / 9]; c = RCX[cx + 2, rc % 9];
                if (rx == 1)
                {
                    w = r; r = c; c = w;
                }
                int rc2 = r * 9 + c;
                AnsN2[rc] = UPbas.AnsNum[rc2];
                if (TransB)
                {
                    UCell P = UPbas.BDL[rc2];
                    UCL.Add(new UCell(rc, P.No, P.FreeB));
                }
            }

            if (TransB)
            {
                UPuzzle UP = pGP.Copy(0, 0);
                UP.BDL = UCL; UP.AnsNum = AnsN2;
                pGNP.SDKProbLst[ID] = UP;
                if (!DspSolB)
                {
                    UP.BDL.ForEach(P => { P.No = Max(P.No, 0); });
                }
                pGNP.CurrentPrbNo = ID;
            }

            SetIDCode(TrPara, AnsN2);
        }
        public void SDK_ProblemListSet(UPuzzle GPx)
        {
            GPx.ID = SDKProbLst.Count;
////            if(GPx.BDL.Any(q=>q.FreeB>0))

            SDKProbLst.Add(GPx);
            if (SDK_Ctrl.FilePut_GenPrb)
            {
                string fName = "AutoGen" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".txt";
                emergencyFilePut("AutoGen", fName);
            }
            CurrentPrbNo = SDKProbLst.Count - 1;
        }
Exemplo n.º 12
0
        //===== Pattern capture =====
        public int patternImport(UPuzzle pGP)
        {
            int nc = 0;

            foreach (var P in pGP.BDL)
            {
                int n = P.No > 0? 1: 0;
                GPat[P.r, P.c] = n;
                nc            += n;
            }
            _PatternToBit( );   //Bit Representation of the Pattern
            return(nc);
        }
        public void _SDK_Ctrl_Initialize()
        {
            AnalyzerMode = "Solve";
            GNPX_Eng.pGP.Sol_ResultLong = "";
            UPuzzle pGP = GetCurrentProble();

            GNPX_Eng.SetGP(pGP);

            GNPX_Eng.AnalyzerCounterReset( );
            GNPX_Eng.AnMan.ResetAnalysisResult(true);   //Return to initial state
            GNPX_Eng.AnMan.Set_CellFreeB();
            SDK_Ctrl.UGPMan     = null;                 //initialize Multi_solver
            GNPX_Eng.pGP.extRes = "";
        }
Exemplo n.º 14
0
        public UPuzzle Copy(int stageNo, int IDm)
        {
            UPuzzle P = (UPuzzle)this.MemberwiseClone();

            P.BDL = new List <UCell>();
            foreach (var q in BDL)
            {
                P.BDL.Add(q.Copy());
            }
            P.HTicks  = DateTime.Now.Ticks;;
            P.stageNo = this.stageNo + 1;
            P.IDm     = IDm;
            return(P);
        }
Exemplo n.º 15
0
//==========================================================
        public bool SnapSaveGP(bool saveAll = false)
        {
            if (SDK_Ctrl.UGPMan == null)
            {
                return(false);
            }

            try{
                if (!SDK_Ctrl.MltAnsSearch)
                {
                    UPuzzle GPX = pGP.Copy(pGP.stageNo + 1, 0);
                    GPX.__SolRes = GPX.Sol_ResultLong.Replace("\r", " ");
                    SDK_Ctrl.UGPMan.MltUProbLst.Add(GPX);
                    SDK_Ctrl.UGPMan.pGPsel = GPX;
                    return(false);
                }

                if (SDK_Ctrl.UGPMan.MltUProbLst == null)
                {
                    SDK_Ctrl.UGPMan.MltUProbLst = new List <UPuzzle>();
                }
                if (SDK_Ctrl.UGPMan.MltUProbLst.Count >= (int)SDK_Ctrl.MltAnsOption["AllMethod"])
                {
                    SDK_Ctrl.MltAnsOption["abortResult"] = pRes.msgUpperLimitBreak;
                    return(false);
                }

                string __SolRes = pGP.Sol_ResultLong.Replace("\r", " ");
                if (saveAll || SDK_Ctrl.UGPMan.MltUProbLst.All(P => (P.__SolRes != __SolRes)))
                {
                    Thread.Sleep(1);
                    int     IDm = SDK_Ctrl.UGPMan.MltUProbLst.Count;
                    UPuzzle GPX = pGP.Copy(pGP.stageNo + 1, IDm);
                    GPX.__SolRes = GPX.Sol_ResultLong.Replace("\r", " ");
                    SDK_Ctrl.UGPMan.MltUProbLst.Add(GPX);
                    SDK_Ctrl.UGPMan.pGPsel = GPX;
                    NuPz_Win.UPP.Add(new UProbS(GPX));
                }
                //  else{
                //      WriteLine("           SnapSave GPSDK_Ctrl.UGPMan.MltUProbLst: "+SDK_Ctrl.UGPMan.MltUProbLst.Count+pGP.__SolRes);
                //  }
            }
            catch (Exception e) { WriteLine(e.Message + "\r" + e.StackTrace); }

            pBDL.ForEach(p => p.ResetAnalysisResult());
            pGP.SolCode = -1;
            return(true);
        }
        public UPuzzle SDK_ToUPuzzle(string st, string name = "", int difLvl = 0, bool saveF = false)
        {
            List <UCell> B = _stringToBDL(st);

            if (B == null)
            {
                return(null);
            }
            var UP = new UPuzzle(999999999, B, name, difLvl);

            if (saveF)
            {
                SDK_Save(UP);
            }
            return(UP);
        }
Exemplo n.º 17
0
//@        private int  solLevelCC=0;
//@        private int  solLevelMax=0;
        private void _Display_GB_GBoard(UPuzzle GPML = null, bool DevelopB = false)
        {
            if (GNP00.AnalyzerMode == "MultiSolve" && __DispMode != "Complated")
            {
                return;
            }
            try{
                UPuzzle currentP = GPML ?? pGP;
                if (currentP == null)
                {
                    return;
                }

                lblUnderAnalysis.Visibility = (GNP00.GSmode == "tabASolve")? Visibility.Visible: Visibility.Hidden;
                Lbl_onAnalyzerM.Visibility  = Visibility.Visible;

                SDKGrp.GBoardPaint(bmpGZero, currentP.BDL, GNP00.GSmode, sNoAssist);
                PB_GBoard.Source = bmpGZero;    //◆currentP.BDL set

                __Set_CellsPZMCount();
                txtProbNo.Text          = (currentP.ID + 1).ToString();
                txtProbName.Text        = currentP.Name;
                nUDDifficultyLevel.Text = currentP.DifLevel.ToString();
                //The following code "pMethod" is rewritten to another thread.
                //This may cause an access violation.
                //here Try with try{...} catch(Exception){...}.
                int DiffL = (GNP00.pGP.pMethod == null)? 0: GNP00.pGP.pMethod.DifLevel; //
                lblCurrentnDifficultyLevel.Content = $"Difficulty: {DiffL}";            //CurrentLevel

                if (DevelopB)
                {
                    _Display_Develop();
                }
                if (GNP00.GSmode == "tabASolve")
                {
                    _Display_ExtResultWin();
                }
            }
            catch (Exception e) {
                WriteLine(e.Message + "\r" + e.StackTrace);
#if DEBUG
                using (var fpW = new StreamWriter("Exception_002e.txt", true, Encoding.UTF8)){
                    fpW.WriteLine($"---{DateTime.Now} {e.Message} \r{e.StackTrace}");
                }
#endif
            }
        }
Exemplo n.º 18
0
        private RenderTargetBitmap bmpPD = new RenderTargetBitmap(176, 176, 96, 96, PixelFormats.Default);//176=18*9+2*4+1*6
        private void _Display_CreateProblem()
        {
            txbNoOfTrials.Text    = GNP00.SDKCntrl.LoopCC.ToString();
            txbNoOfTrialsCum.Text = SDK_Ctrl.TLoopCC.ToString();
            txbBasicPattern.Text  = GNP00.SDKCntrl.PatternCC.ToString();
            int n = gamGen05.Text.ToInt();

            lblNoOfProblems1.Content = (n - _ProgressPer).ToString();

            UPuzzle pGP = GNP00.pGP;

            if (pGP != null)
            {
                int nn = GNP00.SDKProbLst.Count;
                if (nn > 0)
                {
                    txtProbNo.Text          = nn.ToString();
                    txtProbName.Text        = GNP00.SDKProbLst.Last().Name;
                    nUDDifficultyLevel.Text = pGP.DifLevel.ToString();
                }
            }

            string st = AnalyzerLapElaped;

            Lbl_onAnalyzerTS.Content  = st;
            Lbl_onAnalyzerTSM.Content = st;
            txbEpapsedTimeTS3.Text    = st;

            if (__DispMode != null && __DispMode != "")
            {
                _SetScreenProblem();
                displayTimer.Stop();
                AnalyzerLap.Stop();
                btnCreateProblemMlt.Content = pRes.btnCreateProblemMlt;
            }
            __DispMode = "";

            if ((bool)chbCreateProblemEx2.IsChecked)
            {
                SDKGrp.GBPatternDigit(bmpPD, Sol99sta);
            }
            else
            {
                bmpPD.Clear();
            }
            PB_BasePatDig.Source = bmpPD;
        }
Exemplo n.º 19
0
        private UPuzzle CreateDigitToUProblem(int[] SDK81)
        {
            string st = "";

            for (int rc = 0; rc < 81; rc++)
            {
                int nn = SDK81[rc];
                if (nn > 9)
                {
                    nn = 0;
                }
                st += st.ToString();
            }
            UPuzzle UP = GNP00.SDK_ToUPuzzle(st, saveF: true);

            return(UP);
        }
Exemplo n.º 20
0
        private void displayTimer_Tick(object sender, EventArgs e)
        {
            _Display_GB_GBoard();   //******************

            UPuzzle GPML = null;

            if (GNP00.GSmode == "DigRecogCmp" || GNP00.GSmode == "DigRecogCancel")
            {
                if (GNP00.SDK81 != null)
                {
                    GNP00.CurrentPrbNo = 999999999;
                    GPML = GNP00.SDK_ToUPuzzle(GNP00.SDK81, saveF: true);
                    GNP00.CurrentPrbNo = GPML.ID;     //20180731
                }
                displayTimer.Stop();

                _SetScreenProblem();
                GNP00.GSmode = "tabACreate";
            }
//            else{ bdrCamera.BorderBrush=Brushes.Orange;}

/*
 *          bool? B=SDK_Ctrl.paraSearching;
 *          if(B!=null && !(bool)B){
 *              displayTimer.Stop();
 *              _SetScreenProblem( );
 *              SDK_Ctrl.paraSearching=null;
 *          }
 */
            switch (GNP00.GSmode)
            {
            case "DigRecog":
            case "DigRecogTry":
            case "tabACreate": _Display_CreateProblem(); break;

            case "tabBMultiSolve":
            case "tabASolve":  _Display_AnalyzeProb(); break;
            }

            lblResourceMemory.Content = "Memory: " + GC.GetTotalMemory(true).ToString("N0");
            if (((++__GCCounter__) % 1000) == 0)
            {
                GC.Collect(); __GCCounter__ = 0;
            }
        }
        public void SDK_Remove()
        {
            UPuzzle pGP     = GNPX_Eng.pGP;
            int     PnoMemo = CurrentPrbNo;

            if (PnoMemo == SDKProbLst.Count - 1)
            {
                PnoMemo--;
            }
            if (Contain(pGP))
            {
                SDKProbLst.Remove(pGP);
            }
            int id = 0;

            SDKProbLst.ForEach(P => P.ID = (id++));
            CurrentPrbNo = PnoMemo;
        }
        private void DspNumRandmize(UPuzzle P)
        {
            List <int> ranNum = new List <int>();

            for (int r = 0; r < 9; r++)
            {
                ranNum.Add(rnd.Next(0, 9) * 10 + r);
            }
            ranNum.Sort((x, y) => (x - y));
            for (int r = 0; r < 9; r++)
            {
                ranNum[r] %= 10;
            }
            int n;

            P.BDL.ForEach(q => { if ((n = q.No) > 0)
                                 {
                                     q.No = ranNum[n - 1] + 1;
                                 }
                          });
        }
        public void btnTransRes()
        {
            if (pGP.AnsNum == null)
            {
                return;
            }
            UPbas = UPorg.Copy(0, 0);
            UPuzzle tGP = UPorg.Copy(0, 0);

            pGNP.SDKProbLst[ID] = tGP;
            pGNP.GNPX_Eng.pGP   = tGP;

            TrPara = new int[18];
            RCX    = new int[4, 12];
            for (int k = 0; k < 9; k++)
            {
                RCX[0, k] = RCX[1, k] = k;
            }
            for (int k = 0; k < 3; k++)
            {
                RCX[0, k + 9] = RCX[1, k + 9] = k * 3;
            }
        }
        private void Initialize(bool StartF = true)
        {
            pGNPX_Eng.Set_MethodLst_Run(AllMthd: true, GenLogUse: false); //True:All Method
            pGNP.SetSolution(pGP, false, SolAll: true);                   //Solver
            pGP.AnsNum = pGP.BDL.ConvertAll(P => P.No).ToArray();

            TrPara = new int[18];
            RCX    = new int[4, 12];
            for (int k = 0; k < 9; k++)
            {
                RCX[0, k] = RCX[1, k] = k;
            }
            for (int k = 0; k < 3; k++)
            {
                RCX[0, k + 9] = RCX[1, k + 9] = k * 3;
            }

            if (StartF)
            {
                UPorg = pGP.Copy(0, 0);
            }
            UPbas = pGP.Copy(0, 0);
        }
 public SDKSolutionEventArgs(UPuzzle GPX)
 {
     this.UPB = new UProbS(GPX);
     this.GPX = GPX;
 }
Exemplo n.º 26
0
 public UProbS(UPuzzle P)
 {
     this.IDmp1      = P.IDmp1; this.DifLevel = P.DifLevel;
     this.Sol_Result = P.Sol_Result; this.Sol_ResultLong = P.Sol_ResultLong;
 }
        //----------------------------------------------------------------------

        public GNPZ_Engin(GNPXApp000 pGNP00, UPuzzle pGP)
        {
            this.pGNP00 = pGNP00;
            this.pGP    = pGP;
            AnMan       = new GNPX_AnalyzerMan(this);
        }
        public void SDK_TransProbG(string ctrl, bool DspSolB)
        {
            if (pGP.AnsNum == null)
            {
                Initialize();
            }

            int ixM = 0, ixR = TrPara[8], ixC = 1 - ixR, nx, m, n;

            switch (ctrl)
            {
            case "NumChange": break;

            case "Checked": break;

            case "random":  break;

            case "btnPatCVRg":
                ixM = TrPara[0] = (++TrPara[0]) % 6;
                for (int k = 0; k < 3; k++)
                {
                    RCX[ixR, k + 9] = prmX[ixM, k] * 3;
                }
                break;

            case "btnPatCVR123g":
                nx = RCX[ixR, 9]; ixM = TrPara[1] = (++TrPara[1]) % 6;
                for (int k = 0; k < 3; k++)
                {
                    RCX[ixR, k + nx] = prmX[ixM, k] + nx;
                }
                break;

            case "btnPatCVR456g":
                nx = RCX[ixR, 10]; ixM = TrPara[2] = (++TrPara[2]) % 6;
                for (int k = 0; k < 3; k++)
                {
                    RCX[ixR, k + nx] = prmX[ixM, k] + nx;
                }
                break;

            case "btnPatCVR789g":
                nx = RCX[ixR, 11]; ixM = TrPara[3] = (++TrPara[3]) % 6;
                for (int k = 0; k < 3; k++)
                {
                    RCX[ixR, k + nx] = prmX[ixM, k] + nx;
                }
                break;

            case "btnPatCVCg":
                ixM = TrPara[4] = (++TrPara[4]) % 6;
                for (int k = 0; k < 3; k++)
                {
                    RCX[ixC, k + 9] = prmX[ixM, k] * 3;
                }
                break;

            case "btnPatCVC123g":
                nx = RCX[ixC, 9]; ixM = TrPara[5] = (++TrPara[5]) % 6;
                for (int k = 0; k < 3; k++)
                {
                    RCX[ixC, k + nx] = prmX[ixM, k] + nx;
                }
                break;

            case "btnPatCVC456g":
                nx = RCX[ixC, 10]; ixM = TrPara[6] = (++TrPara[6]) % 6;
                for (int k = 0; k < 3; k++)
                {
                    RCX[ixC, k + nx] = prmX[ixM, k] + nx;
                }
                break;

            case "btnPatCVC789g":
                nx = RCX[ixC, 11]; ixM = TrPara[7] = (++TrPara[7]) % 6;
                for (int k = 0; k < 3; k++)
                {
                    RCX[ixC, k + nx] = prmX[ixM, k] + nx;
                }
                break;

#if false
            case "btnTransRtg":     //clockwise
                ixR = TrPara[8] = (++TrPara[8]) % 2;
                ixC = 1 - ixR;
                subTransLR(ixC);
                if (ixR == 0)
                {
                    subTransLR(ixC);
                }
                break;
#endif
            case "btnPatCVRCg":
            case "btnPatCVRCg2":
                ixR = TrPara[8] = (++TrPara[8]) % 2;
                ixC = 1 - ixR;
                if (ctrl == "btnTransRtg")
                {
                    goto case "btnTransLRg";                        //if clockwise,goto  horizontal flip
                }
                break;

            case "btnTransLRg":     //horizontal flip
                subTransLR(ixC);
                break;

            case "btnTransUDg":     //vertical flip
                subTransUD(ixR);
                break;

            //Symmetric transformation
            case "btnPatCVR123987g":     //row 123
                nx = RCX[ixR, 9]; m = TrPara[1]; ixM = TrPara[1] = (m + 1) % 6;
                for (int k = 0; k < 3; k++)
                {
                    RCX[ixR, k + nx] = prmX[ixM, k] + nx;
                }
                nx = RCX[ixR, 11]; n = TrPara[3]; ixM = TrPara[3] = trsX[m, n];
                for (int k = 0; k < 3; k++)
                {
                    RCX[ixR, k + nx] = prmX[ixM, k] + nx;
                }
                break;

            case "btnPatCVC123987g":     //Column 123
                nx = RCX[ixC, 9]; m = TrPara[5]; ixM = TrPara[5] = (m + 1) % 6;
                for (int k = 0; k < 3; k++)
                {
                    RCX[ixC, k + nx] = prmX[ixM, k] + nx;
                }
                nx = RCX[ixC, 11]; n = TrPara[7]; ixM = TrPara[7] = trsX[m, n];
                for (int k = 0; k < 3; k++)
                {
                    RCX[ixC, k + nx] = prmX[ixM, k] + nx;
                }
                break;

            case "btnPatCVR46g":     //row 46
                nx = RCX[ixR, 10]; ixM = TrPara[2] = (TrPara[2] + 3) % 6;
                for (int k = 0; k < 3; k++)
                {
                    RCX[ixR, k + nx] = prmX[ixM, k] + nx;
                }
                break;

            case "btnPatCVC46g":     //Column 46
                nx = RCX[ixC, 10]; ixM = TrPara[6] = (TrPara[6] + 3) % 6;
                for (int k = 0; k < 3; k++)
                {
                    RCX[ixC, k + nx] = prmX[ixM, k] + nx;
                }
                break;
            }

            for (int j = 0; j < 2; j++)
            {
                for (int k = 0; k < 9; k++)
                {
                    nx            = RCX[j, k / 3 + 9];
                    RCX[j + 2, k] = RCX[j, nx + k % 3];
                }
            }

            List <UCell> UCL = new List <UCell>();
            int[]        AnsN2 = new int[81];
            int          r, c, w;

            for (int rc = 0; rc < 81; rc++)
            {
                r = RCX[ixR + 2, rc / 9]; c = RCX[ixC + 2, rc % 9];
                if (ixR == 1)
                {
                    w = r; r = c; c = w;
                }
                int   rc2 = r * 9 + c;
                UCell P   = UPbas.BDL[rc2];
                UCL.Add(new UCell(rc, P.No, P.FreeB));
                AnsN2[rc] = UPbas.AnsNum[rc2];
            }
            UPuzzle UP = pGP.Copy(0, 0);
            UP.BDL = UCL; UP.AnsNum = AnsN2;
            if (ID >= 0)
            {
                pGNP.SDKProbLst[ID] = UP;
            }
            else
            {
                UP.ID = pGP.ID = 0;
                pGNP.SDKProbLst.Add(UP);
            }
            if (!DspSolB)
            {
                UP.BDL.ForEach(P => { P.No = Max(P.No, 0); });
            }
            pGNP.CurrentPrbNo = ID;

            SetIDCode(TrPara, AnsN2);

            /*
             *      string st="RCX:";
             *      for(int j=0; j<4; j++ ){
             *          for(int k=0; k<12; k++ ) st+=" "+RCX[j,k];
             *          st+=" / ";
             *      }
             *      for(int k=0; k<9; k++ ) st+=" "+TrPara[k];
             *      st+="//";
             *      int[] BPw=new int[3];
             *      for(int k=9; k<12; k++ ){BPw[k-9]=TrPara[k]; st+=" "+TrPara[k]; }
             *      WriteLine(st);
             *
             *      Bit81 BP=new Bit81(BPw);
             *      WriteLine(BP);
             */
        }
        public bool AnalyzerControl(CancellationToken ct, ref int ret2, bool SolInfoB)
        {
            List <UCell> XYchainList = new List <UCell>();
            Stopwatch    AnalyzerLap = new Stopwatch();

            AnMan.GStage++;

            bool ret = false;

            try{
                pGP.Sol_ResultLong = "";
                int lvlLow = SDK_Ctrl.lvlLow;
                int lvlHgh = SDK_Ctrl.lvlHgh;
                AnMan.SolversInitialize();

                #region Solve
                int mCC = 0;
                do
                {
                    ret = AnMan.VerifyRoule_SuDoKu();
                    if (!ret)
                    {
                        if (SolInfoB)
                        {
                            pGP.Sol_ResultLong = "No solution";
                        }
                        ret2 = -999888777;
                        return(false);
                    }
                    ret = false;
                    //-------------------------------------------
LblRestart:
                    AnalyzerLap.Start();

                    DateTime MltAnsTimer = DateTime.Now;
                    UPuzzle  GPpre       = null;
                    if (SDK_Ctrl.MltAnsSearch)
                    {
                        GPpre = pGP.Copy(0, 0);
                    }
                    try{
                        if (AnMan.pBDL.All(p => (p.FreeB == 0)))
                        {
                            break;
                        }
                        pGP.SolCode = -1;
                        bool L1SolFound = false;
                        foreach (var P in MethodLst_Run)
                        {
                            if (ct != null && ct.IsCancellationRequested)
                            {
                                return(false);
                            }
                            int lvl    = P.DifLevel;
                            int lvlAbs = Abs(lvl);
                            if (lvlAbs > lvlHgh)
                            {
                                continue;
                            }
                            try{
                                if (SDK_Ctrl.MltAnsSearch) //Multiple Solutions Analysis
                                {
                                    if (L1SolFound && lvlAbs >= 2)
                                    {
                                        break;
                                    }
                                    if (lvlAbs > (int)SDK_Ctrl.MltAnsOption["MaxLevel"])
                                    {
                                        continue;
                                    }
                                    if ((string)SDK_Ctrl.MltAnsOption["abortResult"] != "")
                                    {
                                        GNPX_AnalyzerMessage = (string)SDK_Ctrl.MltAnsOption["abortResult"];
                                        break;
                                    }
                                }
                                else
                                {
                                    if (lvl < 0)
                                    {
                                        continue;           //(negative difficulty method is used only Multiple Solutions Analysis)
                                    }
                                }

                                if (__ChkPrint__)
                                {
                                    WriteLine($"---> method{(mCC++)} :{P.MethodName}");
                                }
                                GNPX_AnalyzerMessage = P.MethodName;
                                if (ct != null && ct.IsCancellationRequested) /*ct.ThrowIfCancellationRequested();*/ return {
                                    (false);
                                }
                                if (pGP.DifLevel < P.DifLevel)
                                {
                                    pGP.DifLevel = P.DifLevel;                                                      //БеTBDБе
                                }
                                if ((ret = P.Method()))
                                {
                                    if (SDK_Ctrl.UGPMan != null && SDK_Ctrl.UGPMan.MltUProbLst != null &&
                                        SDK_Ctrl.UGPMan.MltUProbLst.Any(q => q.SolCode == 1))
                                    {
                                        L1SolFound = true;
                                    }
                                    P.UsedCC++;
                                    pGP.pMethod = P;
                                    if (SDK_Ctrl.UGPMan != null && SDK_Ctrl.UGPMan.pGPsel != null)
                                    {
                                        SDK_Ctrl.UGPMan.pGPsel.pMethod = P;
                                    }

                                    if (__ChkPrint__)
                                    {
                                        WriteLine($"========================> solved {P.MethodName}");
                                    }
                                    if (!SDK_Ctrl.MltAnsSearch)
                                    {
                                        goto succeedBreak;
                                    }
                                }
                            }
                            catch (Exception e) {
                                WriteLine(e.Message + "\r" + e.StackTrace);
                                using (var fpW = new StreamWriter("Exception_201_1.txt", true, Encoding.UTF8)){
                                    fpW.WriteLine($"---{DateTime.Now} {e.Message} \r{e.StackTrace}");
                                }
                                goto LblRestart;
                            }
                        }

                        if (SDK_Ctrl.MltAnsSearch && SDK_Ctrl.UGPMan != null && SDK_Ctrl.UGPMan.MltUProbLst != null)
                        {
                            if (SDK_Ctrl.UGPMan.MltUProbLst.Count > 0)
                            {
                                pGP = SDK_Ctrl.UGPMan.MltUProbLst.First();
                                SDK_Ctrl.UGPMan.pGPsel = pGP;
                                ret = true;
                                goto succeedBreak;
                            }
                        }

                        if (__ChkPrint__)
                        {
                            WriteLine("========================> can not solve");
                        }
                        if (SolInfoB)
                        {
                            pGP.Sol_ResultLong = "can not solve";
                        }
                        ret2 = -999888777;
                        return(false);
                    }
                    catch (OperationCanceledException) {}
                    catch (Exception e) {
                        WriteLine(e.Message + "\r" + e.StackTrace);
                        using (var fpW = new StreamWriter("ExceptionXXX_2.txt", true, Encoding.UTF8)){
                            fpW.WriteLine($"---{DateTime.Now} {e.Message} \r{e.StackTrace}");
                        }
                        goto LblRestart;
                    }
                    finally{
                        AnalyzerLap.Stop();
                        SDK_Ctrl.solLevelNN = Min(SDK_Ctrl.solLevelNN, AnMan.pBDL.Count(p => (p.FreeB != 0)));
                    }
                }while(false);
            }
            catch (ThreadAbortException ex) {
                WriteLine(ex.Message + "\r" + ex.StackTrace);
            }
succeedBreak:            //found
            SdkExecTime = AnalyzerLap.Elapsed;

            #endregion Solve
            return(ret);
        }
 public void SetGP(UPuzzle pGP)
 {
     this.pGP = pGP;
     AnMan.Set_CellFreeB();
     GNPX_AnalyzerMessage = "";
 }