void SetMeshWorth(Pos pos, bool isBlack) { int sixteen = isBlack ? 16 : -16; int four = isBlack ? 4 : -4; int one = isBlack ? 1 : -1; m_MeshWorths[pos.Row, pos.Col] = sixteen; var poses = RoundThreePoses(pos); foreach (var p in poses) { if (IsTouch(p, pos)) { m_MeshWorths[p.Row, p.Col] += four; } else if (IsCusp(p, pos) || IsJumpOne(p, pos)) { m_MeshWorths[p.Row, p.Col] += one; if (LineTwo.Contains(p)) { var lineOne = LinkPoses(p).Intersect(LineOne).First(); m_MeshWorths[lineOne.Row, lineOne.Col] += one; } } } }
Pos TwoEmpty() { UpdateEmptyCount(); var w_blocks = m_WhiteStepBlocks.OrderByDescending(b => b.Steps.Count).ToList(); var b_blocks = m_BlackStepBlocks.OrderByDescending(b => b.Steps.Count).ToList(); foreach (var w_block in w_blocks) // 吃白 { if (w_block.EmptyCount == 2) { var empties = GetLinkEmptySteps(w_block); Pos p = GetPos(w_block, empties); var p1 = GetPos(empties[0]); var p2 = GetPos(empties[1]); if (LineTwo.Contains(p) && LineTwo.Contains(p1) && LinkPoses(p1).Intersect(EmptyPoses).Count() > 2) { return(p1); } else if (LineTwo.Contains(p) && LineTwo.Contains(p2) && LinkPoses(p2).Intersect(EmptyPoses).Count() > 2) { return(p2); } if (FourSharp.Contains(p1) || FourSharp.Contains(p2)) { continue; } if (LinkPoses(p1).Intersect(BlackPoses).Count() >= 1 && CanLevy(p1, p2, p, false)) // 有黑子帮忙 { if (LinkPoses(p2).Intersect(WhitePoses).Count() >= 3) { continue; // 虎口 } return(p2); } else if (LinkPoses(p2).Intersect(BlackPoses).Count() >= 1 && CanLevy(p2, p1, p, false)) { if (LinkPoses(p1).Intersect(WhitePoses).Count() >= 3) { continue; } return(p1); } // 双叫吃 var p1_links = LinkPoses(p1).Intersect(WhitePoses).ToList(); var p2_links = LinkPoses(p2).Intersect(WhitePoses).ToList(); foreach (var p1_l in p1_links) { if (IsCusp(p1_l, p) && LinkPoses(p1_l).Intersect(EmptyPoses).Count() == 2) { if (GetStep(p1_l).EmptyCount != 2) { continue; } if (LinkPoses(p1).Intersect(WhitePoses).Count() >= 3) { continue; } if (LinkPoses(p1).Intersect(EmptyPoses).Count() == 2 && LineOne.Contains(p1)) { continue; } return(p1); } } foreach (var p2_l in p2_links) { if (IsCusp(p2_l, p) && LinkPoses(p2_l).Intersect(EmptyPoses).Count() == 2) { if (GetStep(p2_l).EmptyCount != 2) { continue; } if (LinkPoses(p2).Intersect(WhitePoses).Count() >= 3) { continue; } if (LinkPoses(p2).Intersect(EmptyPoses).Count() == 2 && LineOne.Contains(p2)) { continue; } return(p2); } } // 三路 if (LineThree.Contains(p1) && LineTwo.Contains(p2)) { if (LinkPoses(p1).Intersect(WhitePoses).Count() >= 3) { continue; } return(p1); } else if (LineThree.Contains(p2) && LineTwo.Contains(p1)) { if (LinkPoses(p2).Intersect(WhitePoses).Count() >= 3) { continue; } return(p2); } // 二路 if (LineTwo.Contains(p1)) { if (LinkPoses(p1).Intersect(WhitePoses).Count() < 3) { return(p1); } } else if (LineTwo.Contains(p2)) { if ((LinkPoses(p2).Intersect(WhitePoses).Count() < 3)) { return(p2); } } else if (LineOne.Contains(p1) && LineOne.Contains(p2)) { if (LinkPoses(p1).Intersect(WhitePoses).Count() == 1) { return(p1); } if ((LinkPoses(p2).Intersect(WhitePoses).Count() == 1)) { return(p2); } } // 枷 if (LinkPoses(p1).Intersect(BlackPoses).Count() == 1 && LinkPoses(p2).Intersect(BlackPoses).Count() == 1) { var e_rounds = RoundPoses(p).Intersect(EmptyPoses).ToList(); foreach (var e in e_rounds) { if (IsCusp(e, p) && IsTouch(e, p1) && IsTouch(e, p2)) { return(e); } } } // 打断飞 var r2 = RoundTwoPoses(p).Intersect(WhitePoses).ToList(); foreach (var r in r2) { if (IsFlyOne(p, r) && IsCusp(p1, r) && RoundPoses(r).Intersect(EmptyPoses).Count() == 8) { return(p1); } else if (IsFlyOne(p, r) && IsCusp(p2, r) && RoundPoses(r).Intersect(EmptyPoses).Count() == 8) { return(p2); } } } } foreach (var b_block in b_blocks) // 逃黑 { if (b_block.EmptyCount == 2) { var empties = GetLinkEmptySteps(b_block); Pos p = GetPos(b_block, empties); var p1 = GetPos(empties[0]); var p2 = GetPos(empties[1]); var p1_links = LinkPoses(p1).Intersect(BlackPoses).ToList(); var p2_links = LinkPoses(p2).Intersect(BlackPoses).ToList(); foreach (var p1_l in p1_links) { if (IsCusp(p1_l, p) && GetStep(p1_l).EmptyCount == 2) { if (LinkPoses(p1).Intersect(BlackPoses).Count() >= 3) { continue; } return(p1); } else if (LineOne.Contains(p) && IsCusp(p1_l, p) && GetStep(p1_l).EmptyCount > 2) { foreach (var e in EmptyPoses) { if (IsCusp(e, p) && LinkPoses(e).Intersect(EmptyPoses).Count() == 5) { return(e); } else if (IsCusp(e, p) && LineOne.Contains(e) && LinkPoses(e).Intersect(EmptyPoses).Count() == 4) { return(e); } } } } foreach (var p2_l in p2_links) { if (IsCusp(p2_l, p) && GetStep(p2_l).EmptyCount == 2) { if (LinkPoses(p2).Intersect(BlackPoses).Count() >= 3) { continue; } return(p2); } else if (LineOne.Contains(p) && IsCusp(p2_l, p) && GetStep(p2_l).EmptyCount > 2) { foreach (var e in EmptyPoses) { if (IsCusp(e, p) && LinkPoses(e).Intersect(EmptyPoses).Count() == 5) { return(e); } else if (IsCusp(e, p) && LineOne.Contains(e) && LinkPoses(e).Intersect(EmptyPoses).Count() == 4) { return(e); } } } } } } return(m_InvalidPos); }