X01.Weiqi. 11
In go, a pair of dual functions can be described as a magic bullet, while a pair of three functions can be called a magic bullet. When solving the issue, I accidentally came up with the following code:
// Subquery: p1 and p2 are gas, p2 is the forward direction, and p is the child of escape. Bool CanLevy (Pos p1, Pos p2, Pos p, bool isBlack = true) {if (! IsCusp (p1, p2) return true; if (p = m_InvalidPos) return true; List <Pos> selfPoses = isBlack? BlackPoses: WhitePoses; List <Pos> otherPoses =! IsBlack? BlackPoses: WhitePoses; // when called, don't laugh? Var p1_links = LinkPoses (p1 ). intersect (otherPoses ). toList (); if (p1_links.Count = 1 & p1_links.Intersect (EmptyPoses ). count () = 2) return false; var p2_links = LinkPoses (p2 ). intersect (otherPoses ). toList (); if (p2_links.Count = 1 & p2_links.Intersect (EmptyPoses ). count () = 2) return false; int count = 0; while (true) {if (! InRange (p2.Row, p2.Col) break; bool isRow = p2.Row-p. Row = 0? True: false; int rowOffset = isRow? (Count = 0? P1.Row-p2.Row: p2.Row-p1.Row): 0; int colOffset = isRow? 0: (count = 0? P1.Col-p2.Col: p2.Col-p1.Col); Pos pos = new Pos (p2.Row + rowOffset, p2.Col + colOffset); var rounds = count <5? LinkPoses (pos): RoundTwoPoses (pos); foreach (var r in rounds) {if (isBlack & count <2) continue; // black requires two steps first if (selfPoses. contains (r) return false; if (otherPoses. contains (r) {return true;} count ++; p1 = p; p = p2; p2 = pos;} return true ;}
Among them, the count variable controls the symbol Conversion (count = 0), excluding the old (count <5) and Black play (count <2, in addition, all three cases are indispensable.
Now we can look at it:
When the White 10 expedition, can not escape, the computer chooses the Black 11, and the white 12, can escape, the computer is a smart choice of the Black 13, is perfect!
For more information about downloading the complete code, see the previous blog.