当前位置: 首页>>代码示例>>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;未经允许,请勿转载。