當前位置: 首頁>>代碼示例>>C#>>正文


C# Position.bishop_pair方法代碼示例

本文整理匯總了C#中Portfish.Position.bishop_pair方法的典型用法代碼示例。如果您正苦於以下問題:C# Position.bishop_pair方法的具體用法?C# Position.bishop_pair怎麽用?C# Position.bishop_pair使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Portfish.Position的用法示例。


在下文中一共展示了Position.bishop_pair方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Endgame_KXK

        /// Mate with KX vs K. This function is used to evaluate positions with
        /// King and plenty of material vs a lone king. It simply gives the
        /// attacking side a bonus for driving the defending king towards the edge
        /// of the board, and for keeping the distance between the two kings small.
        /// KXK
        internal static Value Endgame_KXK(Color strongerSide, Position pos)
        {
            Color weakerSide = strongerSide ^ 1;

            Debug.Assert(pos.non_pawn_material(weakerSide) == ValueC.VALUE_ZERO);
            Debug.Assert(pos.piece_count(weakerSide, PieceTypeC.PAWN) == ValueC.VALUE_ZERO);

            // Stalemate detection with lone king
            MList mlist = MListBroker.GetObject(); mlist.pos = 0;
            Movegen.generate_legal(pos, mlist.moves, ref mlist.pos);
            bool any = mlist.pos > 0;
            MListBroker.Free();

            if (pos.sideToMove == weakerSide
                && !pos.in_check()
                && !any)
            {
                return ValueC.VALUE_DRAW;
            }

            Square winnerKSq = pos.king_square(strongerSide);
            Square loserKSq = pos.king_square(weakerSide);

            Value result = pos.non_pawn_material(strongerSide)
                           + pos.piece_count(strongerSide, PieceTypeC.PAWN) * Constants.PawnValueEndgame
                           + MateTable[loserKSq]
                           + DistanceBonus[Utils.square_distance(winnerKSq, loserKSq)];

            if (pos.piece_count(strongerSide, PieceTypeC.QUEEN)!=0
            || pos.piece_count(strongerSide, PieceTypeC.ROOK)!=0
            || pos.bishop_pair(strongerSide))
            {

                result += ValueC.VALUE_KNOWN_WIN;
            }

            return strongerSide == pos.sideToMove ? result : -result;
        }
開發者ID:CVChrisWilson,項目名稱:Portfish,代碼行數:43,代碼來源:Endgame.cs


注:本文中的Portfish.Position.bishop_pair方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。