当前位置: 首页>>代码示例>>C#>>正文


C# Position.is_empty方法代码示例

本文整理汇总了C#中Portfish.Position.is_empty方法的典型用法代码示例。如果您正苦于以下问题:C# Position.is_empty方法的具体用法?C# Position.is_empty怎么用?C# Position.is_empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Portfish.Position的用法示例。


在下文中一共展示了Position.is_empty方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: evaluate_pieces_of_color


//.........这里部分代码省略.........
                        score += ((bonus << 16) + bonus); // Utils.make_score(bonus, bonus);

                        #endregion
                    }

                    if ((Piece == PieceTypeC.ROOK || Piece == PieceTypeC.QUEEN) && Utils.relative_rank_CS(Us, s) >= RankC.RANK_5)
                    {
                        // Major piece on 7th rank
                        if (Utils.relative_rank_CS(Us, s) == RankC.RANK_7
                            && Utils.relative_rank_CS(Us, pos.king_square(Them)) == RankC.RANK_8)
                            score += (Piece == PieceTypeC.ROOK ? RookOn7thBonus : QueenOn7thBonus);

                        // Major piece attacking pawns on the same rank
                        Bitboard pawns = pos.pieces_PTC(PieceTypeC.PAWN, Them) & Utils.rank_bb_S(s);
                        if (pawns != 0)
                        {
                            score += (Piece == PieceTypeC.ROOK ? RookOnPawnBonus : QueenOnPawnBonus) * Bitcount.popcount_1s_Max15(pawns);
                        }
                    }

                    // Special extra evaluation for bishops
                    if (pos.chess960 && (Piece == PieceTypeC.BISHOP))
                    {
                        // An important Chess960 pattern: A cornered bishop blocked by
                        // a friendly pawn diagonally in front of it is a very serious
                        // problem, especially when that pawn is also blocked.
                        if (s == Utils.relative_square(Us, SquareC.SQ_A1)
                            || s == Utils.relative_square(Us, SquareC.SQ_H1))
                        {
                            var d = Utils.pawn_push(Us)
                                    + (Utils.file_of(s) == FileC.FILE_A ? SquareC.DELTA_E : SquareC.DELTA_W);
                            if (pos.piece_on(s + d) == Utils.make_piece(Us, PieceTypeC.PAWN))
                            {
                                if (!pos.is_empty(s + d + Utils.pawn_push(Us)))
                                {
                                    score -= 2 * TrappedBishopA1H1Penalty;
                                }
                                else if (pos.piece_on(s + 2 * d) == Utils.make_piece(Us, PieceTypeC.PAWN))
                                {
                                    score -= TrappedBishopA1H1Penalty;
                                }
                                else
                                {
                                    score -= TrappedBishopA1H1Penalty / 2;
                                }
                            }
                        }
                    }

                    // Special extra evaluation for rooks
                    if (Piece == PieceTypeC.ROOK)
                    {
                        // Open and half-open files
                        f = (s & 7);

                        var halfOpenUs = ((Us == ColorC.WHITE)
                                              ? (ei.pi.halfOpenFilesWHITE & (1 << f))
                                              : (ei.pi.halfOpenFilesBLACK & (1 << f))) != 0;

                        if (halfOpenUs)
                        {
                            if (((Them == ColorC.WHITE)
                                     ? (ei.pi.halfOpenFilesWHITE & (1 << f))
                                     : (ei.pi.halfOpenFilesBLACK & (1 << f))) != 0)
                            {
                                score += RookOpenFileBonus;
开发者ID:torfranz,项目名称:Portfish,代码行数:67,代码来源:Evaluate.cs

示例2: flip

        /// flip() flips position with the white and black sides reversed. This
        /// is only useful for debugging especially for finding evaluation symmetry bugs.
        internal void flip()
        {
            // Make a copy of current position before to start changing
            Position pos = new Position(this);
            clear();

            sideToMove = pos.sideToMove ^ 1;
            thisThread = pos.this_thread();
            nodes = pos.nodes;
            chess960 = pos.chess960;
            startPosPly = pos.startpos_ply_counter();

            for (Square s = SquareC.SQ_A1; s <= SquareC.SQ_H8; s++)
                if (!pos.is_empty(s))
                    put_piece((pos.piece_on(s) ^ 8), Utils.flip_S(s));

            if (pos.can_castle_CR(CastleRightC.WHITE_OO) != 0)
                set_castle_right(ColorC.BLACK, Utils.flip_S(pos.castle_rook_square(ColorC.WHITE, CastlingSideC.KING_SIDE)));
            if (pos.can_castle_CR(CastleRightC.WHITE_OOO) != 0)
                set_castle_right(ColorC.BLACK, Utils.flip_S(pos.castle_rook_square(ColorC.WHITE, CastlingSideC.QUEEN_SIDE)));
            if (pos.can_castle_CR(CastleRightC.BLACK_OO) != 0)
                set_castle_right(ColorC.WHITE, Utils.flip_S(pos.castle_rook_square(ColorC.BLACK, CastlingSideC.KING_SIDE)));
            if (pos.can_castle_CR(CastleRightC.BLACK_OOO) != 0)
                set_castle_right(ColorC.WHITE, Utils.flip_S(pos.castle_rook_square(ColorC.BLACK, CastlingSideC.QUEEN_SIDE)));


            if (pos.st.epSquare != SquareC.SQ_NONE)
                st.epSquare = Utils.flip_S(pos.st.epSquare);

            // Checkers
            st.checkersBB = attackers_to(king_square(sideToMove)) & pieces_C(Utils.flip_C(sideToMove));

            // Hash keys
            st.key = compute_key();
            st.pawnKey = compute_pawn_key();
            st.materialKey = compute_material_key();

            // Incremental scores
            st.psqScore = compute_psq_score();

            // Material
            st.npMaterialWHITE = compute_non_pawn_material(ColorC.WHITE);
            st.npMaterialBLACK = compute_non_pawn_material(ColorC.BLACK);

            Debug.Assert(pos_is_ok());
        }
开发者ID:CVChrisWilson,项目名称:Portfish,代码行数:48,代码来源:Position.cs


注:本文中的Portfish.Position.is_empty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。