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


C# Position.attacks_from_PTS方法代码示例

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


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

示例1: generate_quiet_check

        internal static void generate_quiet_check(Position pos, MoveStack[] ms, ref int mpos)
        {
            /// generate<MV_NON_CAPTURE_CHECK> generates all pseudo-legal non-captures and knight
            /// underpromotions that give check. Returns a pointer to the end of the move list.
            Debug.Assert(!pos.in_check());

            var ci = CheckInfoBroker.GetObject();
            ci.CreateCheckInfo(pos);
            var target = ~pos.occupied_squares;
            var dc = ci.dcCandidates;

            while (dc != 0)
            {
                var from = Utils.pop_lsb(ref dc);
                var pt = Utils.type_of(pos.piece_on(from));

                if (pt == PieceTypeC.PAWN)
                {
                    continue; // Will be generated together with direct checks
                }

                var b = pos.attacks_from_PTS(pt, from) & ~pos.occupied_squares;

                if (pt == PieceTypeC.KING)
                {
                    b &= ~Utils.PseudoAttacks[PieceTypeC.QUEEN][ci.ksq];
                }

                while (b != 0)
                {
                    ms[mpos++].move = Utils.make_move(from, Utils.pop_lsb(ref b));
                }
            }

            generate_all(GenType.QUIET_CHECKS, pos, ms, ref mpos, pos.sideToMove, target, ci);

            CheckInfoBroker.Free();
        }
开发者ID:torfranz,项目名称:Portfish,代码行数:38,代码来源:Movegen.cs

示例2: generate_quiet_check

        internal static void generate_quiet_check(Position pos, MoveStack[] ms, ref int mpos)
        {
            /// generate<MV_NON_CAPTURE_CHECK> generates all pseudo-legal non-captures and knight
            /// underpromotions that give check. Returns a pointer to the end of the move list.
            Debug.Assert(!pos.in_check());

            Color us = pos.sideToMove;
            CheckInfo ci = CheckInfoBroker.GetObject();
            ci.CreateCheckInfo(pos);
            Bitboard dc = ci.dcCandidates;

            while (dc != 0)
            {
                Square from = Utils.pop_1st_bit(ref dc);
                PieceType pt = Utils.type_of(pos.piece_on(from));

                if (pt == PieceTypeC.PAWN)
                    continue; // Will be generated together with direct checks

                Bitboard b = pos.attacks_from_PTS(pt, from) & ~pos.occupied_squares;

                if (pt == PieceTypeC.KING)
                    b &= ~Utils.PseudoAttacks[PieceTypeC.QUEEN][ci.ksq];

                while (b != 0) { ms[mpos++].move = Utils.make_move(from, Utils.pop_1st_bit(ref b)); }
            }

            generate_pawn_moves(us, MoveType.MV_QUIET_CHECK, pos, ms, ref mpos, ci.dcCandidates, ci.ksq);

            generate_direct_checks(PieceTypeC.KNIGHT, pos, ms, ref mpos, us, ci);
            generate_direct_checks(PieceTypeC.BISHOP, pos, ms, ref mpos, us, ci);
            generate_direct_checks(PieceTypeC.ROOK, pos, ms, ref mpos, us, ci);
            generate_direct_checks(PieceTypeC.QUEEN, pos, ms, ref mpos, us, ci);

            if (pos.can_castle_C(us) != 0)
            {
                generate_castle(CastlingSideC.KING_SIDE, true, pos, ms, ref mpos, us);
                generate_castle(CastlingSideC.QUEEN_SIDE, true, pos, ms, ref mpos, us);
            }

            CheckInfoBroker.Free();
        }
开发者ID:CVChrisWilson,项目名称:Portfish,代码行数:42,代码来源:Movegen.cs

示例3: generate_moves

        private static void generate_moves(
            int Pt,
            bool Checks,
            Position pos,
            MoveStack[] mlist,
            ref int mpos,
            int us,
            ulong target,
            CheckInfo ci)
        {
            Debug.Assert(Pt != PieceTypeC.KING && Pt != PieceTypeC.PAWN);

            var pl = pos.pieceList[us][Pt];
            var plPos = 0;
            
            for (var from = pl[plPos]; from != SquareC.SQ_NONE; from = pl[++plPos])
            {
                if (Checks)
                {
                    if ((Pt == PieceTypeC.BISHOP || Pt == PieceTypeC.ROOK || Pt == PieceTypeC.QUEEN)
                        && ((Utils.PseudoAttacks[Pt][from] & (ulong)target & ci.checkSq[Pt]) == 0))
                    {
                        continue;
                    }

                    if ((ci.dcCandidates != 0) && (Utils.bit_is_set(ci.dcCandidates, from) != 0))
                    {
                        continue;
                    }
                }

                var b = pos.attacks_from_PTS(Pt, from) & (ulong)target;

                if (Checks)
                {
                    b &= ci.checkSq[Pt];
                }

                // SERIALIZE(b);
                while (b != 0)
                {
                    mlist[mpos++].move = Utils.make_move(from, Utils.pop_lsb(ref b));
                }
            }
        }
开发者ID:torfranz,项目名称:Portfish,代码行数:45,代码来源:Movegen.cs

示例4: generate_direct_checks

        private static void generate_direct_checks(PieceType Pt, Position pos, MoveStack[] ms, ref int mpos, Color us, CheckInfo ci)
        {
            Debug.Assert(Pt != PieceTypeC.KING && Pt != PieceTypeC.PAWN);

            Bitboard b, target;

            Square[] pl = pos.pieceList[us][Pt];
            int plPos = 0;
            Square from = pl[plPos];

            if ((from = pl[plPos]) != SquareC.SQ_NONE)
            {
                target = ci.checkSq[Pt] & ~pos.occupied_squares; // Non capture checks only

                do
                {
                    if ((Pt == PieceTypeC.BISHOP || Pt == PieceTypeC.ROOK || Pt == PieceTypeC.QUEEN)
                        && ((Utils.PseudoAttacks[Pt][from] & target) == 0))
                        continue;

                    if ((ci.dcCandidates != 0) && (Utils.bit_is_set(ci.dcCandidates, from) != 0))
                        continue;

                    b = pos.attacks_from_PTS(Pt, from) & target;
                    while (b != 0) { ms[mpos++].move = Utils.make_move(from, Utils.pop_1st_bit(ref b)); }

                } while ((from = pl[++plPos]) != SquareC.SQ_NONE);
            }
        }
开发者ID:CVChrisWilson,项目名称:Portfish,代码行数:29,代码来源:Movegen.cs


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