private void _DeathBlossom_SolResult(List <LinkCellALS> LKCAsol, UCell SC, int no, bool stmLink = false) { string st0 = "ALS Death Blossom"; if (stmLink) { st0 += "Ext"; } Color cr = _ColorsLst[0];////Colors.Gold; SC.SetNoBBgColor(SC.FreeB, AttCr3, cr); string st = $"\r Cell r{(SC.r+1)}c{(SC.c+1)} #{SC.FreeB.ToBitStringNZ(9)}"; bool Overlap = false; Bit81 OV = new Bit81(); int k = 0, noB = (1 << no); foreach (var LK in LKCAsol) { int noB2 = 1 << LK.nRCC; cr = _ColorsLst[++k]; LK.ALS.UCellLst.ForEach(P => { P.SetNoBBgColor(noB, AttCr, cr); P.SetNoBBgColor(noB2, AttCr3, cr); if (OV.IsHit(P.rc)) { Overlap = true; } OV.BPSet(P.rc); }); st += $"\r -#{(LK.nRCC+1)}-ALS{k} {LK.ALS.ToStringRCN()}"; } if (Overlap) { st0 += " [overlapping]"; } Result = st0; if (SolInfoB) { ResultLong = st0 + st; } }
private void _developDisp2Ex(Bit81[] GLC) { List <UCell> qBDL = new List <UCell>(); pBDL.ForEach(p => qBDL.Add(p.Copy())); foreach (var P in qBDL.Where(q => q.FreeB > 0)) { int E = 0; for (int n = 0; n < 9; n++) { if (GLC[n].IsHit(P.rc)) { E |= (1 << n); } } if (E > 0) { UCell Q = pBDL[P.rc]; P.SetNoBBgColor(E, Colors.White, Colors.PowderBlue); P.SetNoBColorRev(E, Colors.Blue); Q.SetNoBBgColor(E, Colors.White, Colors.PowderBlue); Q.SetNoBColorRev(E, Colors.Red); int sb = Q.FreeB.DifSet(E); Q.CancelB = E; if (sb.BitCount() == 1) { Q.FixedNo = sb.BitToNum() + 1; SolCode = 1; } else if (sb.BitCount() == 0) { Q.SetCellBgColor(Colors.Violet); } } } devWin.Set_dev_GBoard(qBDL); }
//W-Wing is an algorithm composed of bivalue cell and link. //http://csdenpe.web.fc2.com/page43.html public bool Wwing( ) { Prepare(); CeLKMan.PrepareCellLink(1); //Generate StrongLink if (BVCellLst == null) { BVCellLst = pBDL.FindAll(p => (p.FreeBC == 2)); //BV:BiValue } if (BVCellLst.Count < 2) { return(false); } BVCellLst.Sort((A, B) => (A.FreeB - B.FreeB)); //Important!!! bool Wwing = false; var cmb = new Combination(BVCellLst.Count, 2); int nxt = 99; while (cmb.Successor(nxt)) { UCell P = BVCellLst[cmb.Index[0]]; UCell Q = BVCellLst[cmb.Index[1]]; nxt = 1; if (P.FreeB != Q.FreeB) { nxt = 0; continue; } //BVCellLst is sorted, so possible to skip. if (ConnectedCells[P.rc].IsHit(Q.rc)) { continue; } foreach (var L in CeLKMan.IEGetCellInHouse(1)) //1:StrongLink(Link has a direction. The opposite link is different.) { int no1B = (1 << L.no); if ((P.FreeB & no1B) == 0) { continue; } if (L.rc1 == P.rc || L.rc2 == Q.rc) { continue; } if (!ConnectedCells[P.rc].IsHit(L.rc1)) { continue; //L.rc1 is in the connected area of P.rc? } if (!ConnectedCells[Q.rc].IsHit(L.rc2)) { continue; //L.rc2 is in the connected area of Q.rc? } int no2B = P.FreeB.BitReset(L.no); //another digit string msg2 = ""; Bit81 ELM = ConnectedCells[P.rc] & ConnectedCells[Q.rc]; //ELM:Common part of the influence area of cell P and cell Q foreach (var E in ELM.IEGetUCeNoB(pBDL, no2B)) //Cell/digit in ELM can be excluded { E.CancelB = no2B; Wwing = true; //W-Wing found if (SolInfoB) { msg2 += " " + E.rc.ToRCString(); } } if (!Wwing) { continue; } SolCode = 2; if (SolInfoB) { UCell A = pBDL[L.rc1], B = pBDL[L.rc2]; int noBX = P.FreeB.DifSet(no2B); P.SetNoBBgColor(noBX, AttCr, SolBkCr2); Q.SetNoBBgColor(noBX, AttCr, SolBkCr2); A.SetNoBBgColor(no1B, AttCr, SolBkCr); B.SetNoBBgColor(no1B, AttCr, SolBkCr); string msg0 = $" bvCell: {_XYwingResSub(P)} ,{_XYwingResSub(Q)}"; string msg1 = $" SLink: {A.rc.ToRCNCLString()}-{B.rc.ToRCNCLString()}(#{(L.no+1)})"; Result = $"W Wing Eli.;#{(no2B.BitToNum()+1)} in {msg2.ToString_SameHouseComp()}"; ResultLong = "W Wing\r" + msg0 + "\r" + msg1 + $"\r Eliminated: #{(no2B.BitToNum()+1)} in {msg2.ToString_SameHouseComp()}"; } if (__SimpleAnalizerB__) { return(true); } if (!pAnMan.SnapSaveGP(true)) { return(true); } Wwing = false; } } return(false); }
private bool _ForceChainHouseDispEx(Bit81[] sPass, Bit81[] sTrue, int hs0, int no0) { string dspOpt = GNPXApp000.GMthdOption["ForceLx"]; if (hs0 < 0)// dspOpt:ForceL2" { Result = ResultLong = "ForceChain_House"; if (__SimpleAnalizerB__) { return(true); } pAnMan.SnapSaveGP(true); return(SolCode > 0); } string st0 = "", st2 = ""; for (int nox = 0; nox < 9; nox++) { if (sTrue != null) { if (sTrue[nox].IsZero()) { continue; } foreach (var rc in sTrue[nox].IEGet_rc()) { if (sPass[nox].IsHit(rc)) { continue; } sPass[nox].BPSet(rc); UCell Q = pBDL[rc]; Q.FixedNo = nox + 1; int elm = Q.FreeB.DifSet(1 << nox); Q.CancelB = elm; SolCode = 1; if (SolInfoB) { Q.SetNoBBgColor(1 << nox, Colors.Red, Colors.LightGreen); Q.SetNoBColorRev(elm, Colors.Red); st0 = $"ForceChain_House({_HouseToString(hs0)}/#{(no0+1)}) r{(Q.r+1)}c{(Q.c+1)}/#{(nox+1)} is true"; string st1 = ""; foreach (var P in pBDL.IEGetCellInHouse(hs0, 1 << no0)) { USuperLink USLK = pSprLKsMan.get_L2SprLK(P.rc, no0, FullSearchB: true, DevelopB: false); //Accurate path st1 += "\r" + pSprLKsMan._GenMessage2true(USLK, Q, nox); if (dspOpt != "ForceL2") { P.SetNoBBgColor(1 << no0, Colors.Green, Colors.Yellow); } } st2 = st0 + st1; extRes += "\r" + st2; //(Description of each solution) extRes = extRes.TrimStart(); if (dspOpt == "ForceL0") { Result = ResultLong = st0; if (__SimpleAnalizerB__) { return(true); } if (!pAnMan.SnapSaveGP(false)) { return(true); } extRes = ""; st2 = ""; if (!SDK_Ctrl.MltAnsSearch) { return(true); } } } } } if (SolInfoB && dspOpt == "ForceL1" && st2 != "") { st0 = $"ForceChain_House({_HouseToString(hs0)}/#{(no0+1)})"; Result = ResultLong = st0; if (__SimpleAnalizerB__) { return(true); } if (!pAnMan.SnapSaveGP(false)) { return(true); } extRes = ""; st2 = ""; if (!SDK_Ctrl.MltAnsSearch) { return(true); } } } return(SolCode > 0); }