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


C# Position.do_move方法代码示例

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


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

示例1: move_to_san

        /// move_to_san() takes a position and a legal Move as input and returns its
        /// short algebraic notation representation.
        internal static string move_to_san(Position pos, int m)
        {
            if (m == MoveC.MOVE_NONE)
            {
                return "(none)";
            }

            if (m == MoveC.MOVE_NULL)
            {
                return "(null)";
            }

            Debug.Assert(pos.move_is_legal(m));

            Bitboard others, b;
            Color us = pos.sideToMove;
            var san = new StringBuilder();

            Square from = from_sq(m);
            Square to = to_sq(m);
            Piece pc = pos.piece_on(from);
            PieceType pt = type_of(pc);

            if (type_of_move(m) == MoveTypeC.CASTLING)
            {
                san.Append(to > from ? "O-O" : "O-O-O");
            }
            else
            {
                if (pt != PieceTypeC.PAWN)
                {
                    san.Append(PieceToChar[ColorC.WHITE][pt]); // Upper case

                    // Disambiguation if we have more then one piece of type 'pt' that can
                    // reach 'to' with a legal move.
                    others = b = (pos.attacks_from_PS(pc, to) & pos.pieces_PTC(pt, us)) ^ (ulong)from;
                    while (others != 0)
                    {
                        Move move = make_move(pop_lsb(ref b), to);
                        if (!pos.pl_move_is_legal(move, pos.pinned_pieces()))
                        {
                            others ^= (ulong)from_sq(move);
                        }
                    }

                    if (others != 0)
                    {
                        if ((others & file_bb_S(from)) == 0)
                        {
                            san.Append(file_to_char(file_of(from)));
                        }
                        else if ((others & rank_bb_S(from)) == 0)
                        {
                            san.Append(rank_to_char(rank_of(from)));
                        }
                        else
                        {
                            san.Append(square_to_string(from));
                        }
                    }
                }
                else if (pos.is_capture(m))
                {
                    san.Append(file_to_char(file_of(from)));
                }

                if (pos.is_capture(m))
                {
                    san.Append('x');
                }

                san.Append(square_to_string(to));

                if (type_of_move(m) == MoveTypeC.PROMOTION)
                {
                    san.Append('=');
                    san.Append(PieceToChar[ColorC.WHITE][promotion_type(m)]);
                }
            }

            var ci = CheckInfoBroker.GetObject();
            ci.CreateCheckInfo(pos);
            if (pos.move_gives_check(m, ci))
            {
                var st = new StateInfo();
                pos.do_move(m, st);
                var mlist = MListBroker.GetObject();
                mlist.pos = 0;
                Movegen.generate_legal(pos, mlist.moves, ref mlist.pos);
                san.Append(mlist.pos > 0 ? "+" : "#");
                MListBroker.Free();
                pos.undo_move(m);
            }
            CheckInfoBroker.Free();

            return san.ToString();
        }
开发者ID:torfranz,项目名称:Portfish,代码行数:99,代码来源:Utils.cs

示例2: move_to_san

        /// move_to_san() takes a position and a move as input, where it is assumed
        /// that the move is a legal move for the position. The return value is
        /// a string containing the move in short algebraic notation.
        internal static string move_to_san(Position pos, Move m)
        {
            if (m == MoveC.MOVE_NONE)
                return "(none)";

            if (m == MoveC.MOVE_NULL)
                return "(null)";

            Debug.Assert(is_ok_M(m));

            Bitboard attackers;
            bool ambiguousMove, ambiguousFile, ambiguousRank;
            Square sq, from = from_sq(m);
            Square to = to_sq(m);
            PieceType pt = type_of(pos.piece_moved(m));

            StringBuilder san = new StringBuilder();

            if (is_castle(m))
                san.Append((to_sq(m) < from_sq(m) ? "O-O-O" : "O-O"));
            else
            {
                if (pt != PieceTypeC.PAWN)
                {
                    san.Append(piece_type_to_char(pt).ToString());

                    // Disambiguation if we have more then one piece with destination 'to'
                    // note that for pawns is not needed because starting file is explicit.
                    attackers = pos.attackers_to(to) & pos.pieces_PTC(pt, pos.sideToMove);
                    xor_bit(ref attackers, from);
                    ambiguousMove = ambiguousFile = ambiguousRank = false;

                    while (attackers != 0)
                    {
                        sq = pop_1st_bit(ref attackers);

                        // Pinned pieces are not included in the possible sub-set
                        if (!pos.pl_move_is_legal(make_move(sq, to), pos.pinned_pieces()))
                            continue;

                        if (file_of(sq) == file_of(from))
                            ambiguousFile = true;

                        if (rank_of(sq) == rank_of(from))
                            ambiguousRank = true;

                        ambiguousMove = true;
                    }

                    if (ambiguousMove)
                    {
                        if (!ambiguousFile)
                            san.Append(file_to_char(file_of(from)));
                        else if (!ambiguousRank)
                            san.Append(rank_to_char(rank_of(from)));
                        else
                            san.Append(square_to_string(from));
                    }
                }

                if (pos.is_capture(m))
                {
                    if (pt == PieceTypeC.PAWN)
                        san.Append(file_to_char(file_of(from)));

                    san.Append('x');
                }

                san.Append(square_to_string(to));

                if (is_promotion(m))
                {
                    san.Append('=');
                    san.Append(piece_type_to_char(promotion_type(m)));
                }
            }

            CheckInfo ci = CheckInfoBroker.GetObject();
            ci.CreateCheckInfo(pos);
            if (pos.move_gives_check(m, ci))
            {
                StateInfo st = new StateInfo();
                pos.do_move(m, st);
                MList mlist = MListBroker.GetObject(); mlist.pos = 0;
                Movegen.generate_legal(pos, mlist.moves, ref mlist.pos);
                san.Append(mlist.pos > 0 ? "+" : "#");
                MListBroker.Free();
                pos.undo_move(m);
            }
            CheckInfoBroker.Free();

            return san.ToString();
        }
开发者ID:stevemulligan,项目名称:Portfish,代码行数:96,代码来源:Utils.cs

示例3: set_position

        // set_position() is called when engine receives the "position" UCI
        // command. The function sets up the position described in the given
        // fen string ("fen") or the starting position ("startpos") and then
        // makes the moves given in the following move list ("moves").
        internal static void set_position(Position pos, Stack<string> stack)
        {
            Move m;
            string token, fen = string.Empty;

            token = stack.Pop();

            if (token == "startpos")
            {
                fen = StartFEN;
                if (stack.Count > 0) { token = stack.Pop(); } // Consume "moves" token if any
            }
            else if (token == "fen")
                while ((stack.Count > 0) && (token = stack.Pop()) != "moves")
                    fen += token + " ";
            else
                return;

            pos.from_fen(fen, bool.Parse(OptionMap.Instance["UCI_Chess960"].v), Threads.main_thread());

            // Parse move list (if any)
            while ((stack.Count > 0) && (m = Utils.move_from_uci(pos, token = stack.Pop())) != MoveC.MOVE_NONE)
            {
                pos.do_move(m, StateRingBuf[SetupStatePos]);

                // Increment pointer to StateRingBuf circular buffer
                SetupStatePos = (SetupStatePos + 1) % 102;
            }
        }
开发者ID:CVChrisWilson,项目名称:Portfish,代码行数:33,代码来源:Uci.cs

示例4: search


//.........这里部分代码省略.........
                        return beta - 1;
                    }
                }
            }

            // Step 9. ProbCut (is omitted in PV nodes)
            // If we have a very good capture (i.e. SEE > seeValues[captured_piece_type])
            // and a reduced search returns a value much above beta, we can (almost) safely
            // prune the previous move.
            if (!PvNode && !inCheck
                && excludedMove == MoveC.MOVE_NONE
                && depth >= RazorDepth + DepthC.ONE_PLY
                && (ss[ssPos].skipNullMove == 0)
                && Math.Abs(beta) < ValueC.VALUE_MATE_IN_MAX_PLY)
            {
                Value rbeta = beta + 200;
                Depth rdepth = depth - DepthC.ONE_PLY - 3 * DepthC.ONE_PLY;

                Debug.Assert(rdepth >= DepthC.ONE_PLY);
                Debug.Assert(ss[ssPos - 1].currentMove != MoveC.MOVE_NONE);
                Debug.Assert(ss[ssPos - 1].currentMove != MoveC.MOVE_NULL);

                MovePicker mp2 = MovePickerBroker.GetObject();
                mp2.MovePickerC(pos, ttMove, H, pos.captured_piece_type());
                CheckInfo ci2 = CheckInfoBroker.GetObject();
                ci2.CreateCheckInfo(pos);

                while ((move = mp2.next_move()) != MoveC.MOVE_NONE)
                {
                    if (pos.pl_move_is_legal(move, ci2.pinned))
                    {
                        ss[ssPos].currentMove = move;
                        if (st == null) { st = StateInfoBroker.GetObject(); }
                        pos.do_move(move, st, ci2, pos.move_gives_check(move, ci2));
                        value = -search(NodeTypeC.NonPV, pos, ss, ssPos + 1, -rbeta, -rbeta + 1, rdepth);
                        pos.undo_move(move);
                        if (value >= rbeta)
                        {
                            if (st != null) { st.previous = null; StateInfoBroker.Free(); }
                            CheckInfoBroker.Free();
                            MovePickerBroker.Free(mp2);
                            MovesSearchedBroker.Free();
                            return value;
                        }
                    }
                }

                CheckInfoBroker.Free();
                MovePickerBroker.Free(mp2);
            }

            // Step 10. Internal iterative deepening
            if (ttMove == MoveC.MOVE_NONE
                && depth >= IIDDepth[PvNode ? 1 : 0]
                && (PvNode || (!inCheck && ss[ssPos].eval + IIDMargin >= beta)))
            {
                Depth d = (PvNode ? depth - 2 * DepthC.ONE_PLY : depth / 2);

                ss[ssPos].skipNullMove = 1;
                search(PvNode ? NodeTypeC.PV : NodeTypeC.NonPV, pos, ss, ssPos, alpha, beta, d);
                ss[ssPos].skipNullMove = 0;

                tteHasValue = TT.probe(posKey, ref ttePos, out tte);
                ttMove = (tteHasValue) ? tte.move() : MoveC.MOVE_NONE;
            }
            else
开发者ID:stevemulligan,项目名称:Portfish,代码行数:67,代码来源:Search.cs

示例5: extract_pv_from_tt

        /// RootMove::extract_pv_from_tt() builds a PV by adding moves from the TT table.
        /// We consider also failing high nodes and not only BOUND_EXACT nodes so to
        /// allow to always have a ponder move even when we fail high at root, and a
        /// long PV to print that is important for position analysis.
        internal void extract_pv_from_tt(Position pos)
        {
            StateInfoArray sia = StateInfoArrayBroker.GetObject();

            int stPos = 0;
            TTEntry tte;
            int ply = 1;
            Move m = pv[0];

            Debug.Assert(m != MoveC.MOVE_NONE && pos.is_pseudo_legal(m));

            pv.Clear();
            pv.Add(m);
            pos.do_move(m, sia.state[stPos++]);

            UInt32 ttePos = 0;

            while (TT.probe(pos.key(), ref ttePos, out tte)
               && (m = tte.move()) != MoveC.MOVE_NONE // Local copy, TT entry could change
               && pos.is_pseudo_legal(m)
               && pos.pl_move_is_legal(m, pos.pinned_pieces())
               && ply < Constants.MAX_PLY
               && (!pos.is_draw(false) || ply < 2))
            {
                pv.Add(m);
                pos.do_move(m, sia.state[stPos++]);
                ply++;
            }
            pv.Add(MoveC.MOVE_NONE);

            do pos.undo_move(pv[--ply]); while (ply != 0);

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

示例6: qsearch


//.........这里部分代码省略.........
                    && enoughMaterial
                    && ((move & (3 << 14)) != (1 << 14))
                    && !pos.is_passed_pawn_push(move))
                {
                    futilityValue = futilityBase
                                   + Position.PieceValueEndgame[pos.board[move & 0x3F]]
                                   + (((move & (3 << 14)) == (2 << 14)) ? Constants.PawnValueEndgame : ValueC.VALUE_ZERO);

                    if (futilityValue < beta)
                    {
                        if (futilityValue > bestValue)
                            bestValue = futilityValue;

                        continue;
                    }

                    // Prune moves with negative or equal SEE
                    if (futilityBase < beta
                        && depth < DepthC.DEPTH_ZERO
                        && pos.see(move, false) <= 0)
                        continue;
                }

                // Detect non-capture evasions that are candidate to be pruned
                evasionPrunable = !PvNode
                                 && inCheck
                                 && bestValue > ValueC.VALUE_MATED_IN_MAX_PLY
                                 && !(((pos.board[move & 0x3F] != PieceC.NO_PIECE) && !((move & (3 << 14)) == (3 << 14))) || ((move & (3 << 14)) == (2 << 14)))
                                 && ((pos.st.castleRights & (CastleRightC.WHITE_ANY << (pos.sideToMove << 1))) == 0);

                // Don't search moves with negative SEE values
                if (!PvNode
                    && move != ttMove
                    && (!inCheck || evasionPrunable)
                    && (move & (3 << 14)) != (1 << 14)
                    && pos.see(move, true) < 0)
                    continue;

                // Don't search useless checks
                if (!PvNode
                    && !inCheck
                    && givesCheck
                    && move != ttMove
                    && !(((move & (3 << 14)) != 0) ? ((move & (3 << 14)) != (3 << 14)) : (pos.board[move & 0x3F] != PieceC.NO_PIECE))
                    && ss[ssPos].eval + Constants.PawnValueMidgame / 4 < beta
                    && !check_is_dangerous(pos, move, futilityBase, beta))
                    continue;

                // Check for legality only before to do the move
                if (!pos.pl_move_is_legal(move, ci.pinned))
                    continue;

                ss[ssPos].currentMove = move;

                // Make and search the move
                if (st == null) { st = StateInfoBroker.GetObject(); }
                pos.do_move(move, st, ci, givesCheck);
                value = -qsearch(NT, pos, ss, ssPos + 1, -beta, -alpha, depth - DepthC.ONE_PLY);
                pos.undo_move(move);

                Debug.Assert(value > -ValueC.VALUE_INFINITE && value < ValueC.VALUE_INFINITE);

                // New best move?
                if (value > bestValue)
                {
                    bestValue = value;
                    bestMove = move;

                    if (PvNode
                        && value > alpha
                        && value < beta) // We want always alpha < beta
                        alpha = value;
                }
            }

            // All legal moves have been searched. A special case: If we're in check
            // and no legal moves were found, it is checkmate.
            if (inCheck && bestValue == -ValueC.VALUE_INFINITE)
            {
                if (st != null) { st.previous = null; StateInfoBroker.Free(); }
                CheckInfoBroker.Free();
                MovePickerBroker.Free(mp);
                return Utils.mated_in(ss[ssPos].ply); // Plies to mate from the root
            }

            // Update transposition table
            move = bestValue <= oldAlpha ? MoveC.MOVE_NONE : bestMove;
            bt = bestValue <= oldAlpha ? Bound.BOUND_UPPER
                 : bestValue >= beta ? Bound.BOUND_LOWER : Bound.BOUND_EXACT;

            TT.store(pos.key(), value_to_tt(bestValue, ss[ssPos].ply), bt, ttDepth, move, ss[ssPos].eval, evalMargin);

            Debug.Assert(bestValue > -ValueC.VALUE_INFINITE && bestValue < ValueC.VALUE_INFINITE);

            if (st != null) { st.previous = null; StateInfoBroker.Free(); }
            CheckInfoBroker.Free();
            MovePickerBroker.Free(mp);

            return bestValue;
        }
开发者ID:stevemulligan,项目名称:Portfish,代码行数:101,代码来源:Search.cs

示例7: perft

        /// Search::perft() is our utility to verify move generation. All the leaf nodes
        /// up to the given depth are generated and counted and the sum returned.
        internal static Int64 perft(Position pos, Depth depth)
        {
            StateInfo st = new StateInfo();
            Int64 cnt = 0;

            MList mlist = MListBroker.GetObject(); mlist.pos = 0;
            Movegen.generate_legal(pos, mlist.moves, ref mlist.pos);

            // At the last ply just return the number of moves (leaf nodes)
            if (depth == DepthC.ONE_PLY)
            {
                int retval = mlist.pos;
                MListBroker.Free();
                return retval;
            }

            CheckInfo ci = CheckInfoBroker.GetObject();
            ci.CreateCheckInfo(pos);
            for (int i = 0; i < mlist.pos; ++i)
            {
                MoveStack ms = mlist.moves[i];
                pos.do_move(ms.move, st, ci, pos.move_gives_check(ms.move, ci));
                cnt += perft(pos, depth - DepthC.ONE_PLY);
                pos.undo_move(ms.move);
            }
            CheckInfoBroker.Free();
            MListBroker.Free();
            return cnt;
        }
开发者ID:stevemulligan,项目名称:Portfish,代码行数:31,代码来源:Search.cs

示例8: insert_pv_in_tt

        // insert_pv_in_tt() is called at the end of a search iteration, and inserts
        // the PV back into the TT. This makes sure the old PV moves are searched
        // first, even if the old TT entries have been overwritten.
        internal void insert_pv_in_tt(Position pos)
        {
            StateInfoArray sia = StateInfoArrayBroker.GetObject();

            int stPos = 0;
            TTEntry tte;
            bool tteHasValue;
            Key k;
            Value v, m = ValueC.VALUE_NONE;
            int ply = 0;
            UInt32 ttePos = 0;

            Debug.Assert(pv[ply] != MoveC.MOVE_NONE && pos.is_pseudo_legal(pv[ply]));

            do
            {
                k = pos.key();
                tteHasValue = TT.probe(k, ref ttePos, out tte);

                // Don't overwrite existing correct entries
                if ((!tteHasValue) || tte.move() != pv[ply])
                {
                    v = (pos.in_check() ? ValueC.VALUE_NONE : Evaluate.do_evaluate(false, pos, ref m));
                    TT.store(k, ValueC.VALUE_NONE, Bound.BOUND_NONE, DepthC.DEPTH_NONE, pv[ply], v, m);
                }
                pos.do_move(pv[ply], sia.state[stPos++]);
            } while (pv[++ply] != MoveC.MOVE_NONE);

            do pos.undo_move(pv[--ply]); while (ply != 0);

            StateInfoArrayBroker.Free();
        }
开发者ID:stevemulligan,项目名称:Portfish,代码行数:35,代码来源:Search.cs

示例9: search


//.........这里部分代码省略.........
                        return beta - 1;
                    }
                }
            }

            // Step 9. ProbCut (is omitted in PV nodes)
            // If we have a very good capture (i.e. SEE > seeValues[captured_piece_type])
            // and a reduced search returns a value much above beta, we can (almost) safely
            // prune the previous move.
            if (!PvNode && !inCheck && excludedMove == MoveC.MOVE_NONE && depth >= 4 * DepthC.ONE_PLY + DepthC.ONE_PLY
                && (ss[ssPos].skipNullMove == 0) && Math.Abs(beta) < ValueC.VALUE_MATE_IN_MAX_PLY)
            {
                var rbeta = beta + 200;
                var rdepth = depth - DepthC.ONE_PLY - 3 * DepthC.ONE_PLY;

                Debug.Assert(rdepth >= DepthC.ONE_PLY);
                Debug.Assert(ss[ssPos - 1].currentMove != MoveC.MOVE_NONE);
                Debug.Assert(ss[ssPos - 1].currentMove != MoveC.MOVE_NULL);

                var mp2 = MovePickerBroker.GetObject();
                mp2.MovePickerC(pos, ttMove, H, pos.captured_piece_type());
                var ci2 = CheckInfoBroker.GetObject();
                ci2.CreateCheckInfo(pos);

                while ((move = mp2.next_move()) != MoveC.MOVE_NONE)
                {
                    if (pos.pl_move_is_legal(move, ci2.pinned))
                    {
                        ss[ssPos].currentMove = move;
                        if (st == null)
                        {
                            st = StateInfoBroker.GetObject();
                        }
                        pos.do_move(move, st, ci2, pos.move_gives_check(move, ci2));
                        value = -search(NodeTypeC.NonPV, pos, ss, ssPos + 1, -rbeta, -rbeta + 1, rdepth);
                        pos.undo_move(move);
                        if (value >= rbeta)
                        {
                            if (st != null)
                            {
                                st.previous = null;
                                StateInfoBroker.Free();
                            }
                            CheckInfoBroker.Free();
                            MovePickerBroker.Free(mp2);
                            MovesSearchedBroker.Free();
                            return value;
                        }
                    }
                }

                CheckInfoBroker.Free();
                MovePickerBroker.Free(mp2);
            }

            // Step 10. Internal iterative deepening
            if (ttMove == MoveC.MOVE_NONE && depth >= (PvNode ? 5 * DepthC.ONE_PLY : 8 * DepthC.ONE_PLY)
                && (PvNode || (!inCheck && ss[ssPos].staticEval + 256 >= beta)))
            {
                var d = (PvNode ? depth - 2 * DepthC.ONE_PLY : depth / 2);

                ss[ssPos].skipNullMove = 1;
                search(PvNode ? NodeTypeC.PV : NodeTypeC.NonPV, pos, ss, ssPos, alpha, beta, d);
                ss[ssPos].skipNullMove = 0;

                tteHasValue = TT.probe(posKey, ref ttePos, out tte);
开发者ID:torfranz,项目名称:Portfish,代码行数:67,代码来源:Search.cs

示例10: qsearch


//.........这里部分代码省略.........
                    && move != ttMove 
                    && (!InCheck || evasionPrunable) 
                    && Utils.type_of_move(move) != MoveTypeC.PROMOTION
                    && pos.see(move, true) < 0)
                {
                    continue;
                }

                // Don't search useless checks
                if (!PvNode 
                    && !InCheck 
                    && givesCheck 
                    && move != ttMove
                    && !pos.is_capture_or_promotion(move)
                    && ss[ssPos].staticEval + Constants.PawnValueMidgame / 4 < beta
                    && !check_is_dangerous(pos, move, futilityBase, beta))
                {
                    continue;
                }

                // Check for legality only before to do the move
                if (!pos.pl_move_is_legal(move, ci.pinned))
                {
                    continue;
                }

                ss[ssPos].currentMove = move;

                // Make and search the move
                if (st == null)
                {
                    st = StateInfoBroker.GetObject();
                }
                pos.do_move(move, st, ci, givesCheck);
                value = -qsearch(NT, givesCheck, pos, ss, ssPos + 1, -beta, -alpha, depth - DepthC.ONE_PLY);
                pos.undo_move(move);

                Debug.Assert(value > -ValueC.VALUE_INFINITE && value < ValueC.VALUE_INFINITE);

                // Check for new best move
                if (value > bestValue)
                {
                    bestValue = value;
                    
                    if (value > alpha)
                    {
                        if (PvNode && value < beta) // Update alpha here! Always alpha < beta
                        {
                            alpha = value;
                            bestMove = move;
                        }
                        else // Fail high
                        {
                            TT.store(posKey, value_to_tt(value, ss[ssPos].ply), Bound.BOUND_LOWER, 
                                ttDepth, move, ss[ssPos].staticEval, ss[ssPos].evalMargin);

                            if (st != null)
                            {
                                st.previous = null;
                                StateInfoBroker.Free();
                            }
                            CheckInfoBroker.Free();
                            MovePickerBroker.Free(mp);
                            return value;
                        }
                    }
开发者ID:torfranz,项目名称:Portfish,代码行数:67,代码来源:Search.cs

示例11: insert_pv_in_tt

        // insert_pv_in_tt() is called at the end of a search iteration, and inserts
        // the PV back into the TT. This makes sure the old PV moves are searched
        // first, even if the old TT entries have been overwritten.
        internal void insert_pv_in_tt(Position pos)
        {
            var sia = StateInfoArrayBroker.GetObject();

            var stPos = 0;
            TTEntry tte;
            bool tteHasValue;
            
            int v, m = 0;
            var ply = 0;
            uint ttePos = 0;
            
            do
            {
                tteHasValue = TT.probe(pos.key(), ref ttePos, out tte);

                if ((!tteHasValue) || tte.move() != this.pv[ply]) // Don't overwrite existing correct entries
                {
                    if (pos.in_check())
                    {
                        v = m = ValueC.VALUE_NONE;
                    }
                    else
                    {
                        v = Evaluate.do_evaluate(false, pos, ref m);
                    }

                    TT.store(pos.key(), ValueC.VALUE_NONE, Bound.BOUND_NONE, DepthC.DEPTH_NONE, this.pv[ply], v, m);
                }

                Debug.Assert(pos.move_is_legal(pv[ply]));
                pos.do_move(this.pv[ply++], sia.state[stPos++]);
            }
            while (this.pv[ply] != MoveC.MOVE_NONE);

            while (ply != 0)
            {
                pos.undo_move(this.pv[--ply]);
            }

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

示例12: extract_pv_from_tt

        /// RootMove::extract_pv_from_tt() builds a PV by adding moves from the TT table.
        /// We consider also failing high nodes and not only BOUND_EXACT nodes so to
        /// allow to always have a ponder move even when we fail high at root, and a
        /// long PV to print that is important for position analysis.
        internal void extract_pv_from_tt(Position pos)
        {
            var sia = StateInfoArrayBroker.GetObject();

            var stPos = 0;
            TTEntry tte;
            bool tteHasValue;
            var ply = 0;
            var m = this.pv[0];

            this.pv.Clear();
            
            uint ttePos = 0;
            do
            {
                this.pv.Add(m);

                Debug.Assert(pos.move_is_legal(pv[ply]));
                pos.do_move(pv[ply++], sia.state[stPos++]);
                tteHasValue = TT.probe(pos.key(), ref ttePos, out tte);
            } while (tteHasValue
                    && pos.is_pseudo_legal(m = tte.move()) // Local copy, TT could change
                    && pos.pl_move_is_legal(m, pos.pinned_pieces())
                    && ply < Constants.MAX_PLY
                    && (!pos.is_draw(false) || ply < 2));
            ;
            
            this.pv.Add(MoveC.MOVE_NONE); // Must be zero-terminating

            while (ply != 0)
            {
                pos.undo_move(this.pv[--ply]);
            }

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


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