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


C# Position.this_thread方法代码示例

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


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

示例1: split

        // split() does the actual work of distributing the work at a node between
        // several available threads. If it does not succeed in splitting the node
        // (because no idle threads are available, or because we have no unused split
        // point objects), the function immediately returns. If splitting is possible, a
        // SplitPoint object is initialized with all the data that must be copied to the
        // helper threads and then helper threads are told that they have been assigned
        // work. This will cause them to instantly leave their idle loops and call
        // search(). When all threads have returned from search() then split() returns.
        internal static Value split(bool Fake, Position pos, Stack[] ss, int ssPos, Value alpha, Value beta,
                                    Value bestValue, ref Move bestMove, Depth depth, Move threatMove,
                                    int moveCount, MovePicker mp, int nodeType)
        {
            Debug.Assert(pos.pos_is_ok());
            Debug.Assert(bestValue > -ValueC.VALUE_INFINITE);
            Debug.Assert(bestValue <= alpha);
            Debug.Assert(alpha < beta);
            Debug.Assert(beta <= ValueC.VALUE_INFINITE);
            Debug.Assert(depth > DepthC.DEPTH_ZERO);

            Thread master = pos.this_thread();

            if (master.splitPointsCnt >= Constants.MAX_SPLITPOINTS_PER_THREAD)
                return bestValue;

            // Pick the next available split point from the split point stack
            SplitPoint sp = master.splitPoints[master.splitPointsCnt];

            sp.parent = master.curSplitPoint;
            sp.master = master;
            sp.cutoff = false;
            sp.slavesMask = 1UL << master.idx;
#if ACTIVE_REPARENT
            sp.allSlavesRunning = true;
#endif

            sp.depth = depth;
            sp.bestMove = bestMove;
            sp.threatMove = threatMove;
            sp.alpha = alpha;
            sp.beta = beta;
            sp.nodeType = nodeType;
            sp.bestValue = bestValue;
            sp.mp = mp;
            sp.moveCount = moveCount;
            sp.pos = pos;
            sp.nodes = 0;
            sp.ss = ss;
            sp.ssPos = ssPos;

            Debug.Assert(master.is_searching);
            master.curSplitPoint = sp;

            int slavesCnt = 0;

            ThreadHelper.lock_grab(sp.Lock);
            ThreadHelper.lock_grab(splitLock);

            for (int i = 0; i < size() && !Fake; ++i)
                if (threads[i].is_available_to(master))
                {
                    sp.slavesMask |= 1UL << i;
                    threads[i].curSplitPoint = sp;
                    threads[i].is_searching = true; // Slave leaves idle_loop()

                    if (useSleepingThreads)
                        threads[i].wake_up();

                    if (++slavesCnt + 1 >= maxThreadsPerSplitPoint) // Master is always included
                        break;
                }

            master.splitPointsCnt++;

            ThreadHelper.lock_release(splitLock);
            ThreadHelper.lock_release(sp.Lock);

            // Everything is set up. The master thread enters the idle loop, from which
            // it will instantly launch a search, because its is_searching flag is set.
            // We pass the split point as a parameter to the idle loop, which means that
            // the thread will return from the idle loop when all slaves have finished
            // their work at this split point.
            if (slavesCnt != 0 || Fake)
            {
                master.idle_loop(sp, null);
                // In helpful master concept a master can help only a sub-tree of its split
                // point, and because here is all finished is not possible master is booked.
                Debug.Assert(!master.is_searching);
            }

            // We have returned from the idle loop, which means that all threads are
            // finished. Note that setting is_searching and decreasing activeSplitPoints is
            // done under lock protection to avoid a race with Thread::is_available_to().
            ThreadHelper.lock_grab(sp.Lock); // To protect sp->nodes
            ThreadHelper.lock_grab(splitLock);

            master.is_searching = true;
            master.splitPointsCnt--;
            master.curSplitPoint = sp.parent;
            pos.nodes += sp.nodes;
            bestMove = sp.bestMove;
//.........这里部分代码省略.........
开发者ID:stevemulligan,项目名称:Portfish,代码行数:101,代码来源:Thread.cs

示例2: search

        // search<>() is the main search function for both PV and non-PV nodes and for
        // normal and SplitPoint nodes. When called just after a split point the search
        // is simpler because we have already probed the hash table, done a null move
        // search, and searched the first move before splitting, we don't have to repeat
        // all this work again. We also don't need to store anything to the hash table
        // here: This is taken care of after we return from the split point.
        internal static Value search(NodeType NT, Position pos, Stack[] ss, int ssPos, Value alpha, Value beta, Depth depth)
        {
            bool PvNode = (NT == NodeTypeC.PV || NT == NodeTypeC.Root || NT == NodeTypeC.SplitPointPV || NT == NodeTypeC.SplitPointRoot);
            bool SpNode = (NT == NodeTypeC.SplitPointPV || NT == NodeTypeC.SplitPointNonPV || NT == NodeTypeC.SplitPointRoot);
            bool RootNode = (NT == NodeTypeC.Root || NT == NodeTypeC.SplitPointRoot);

            Debug.Assert(alpha >= -ValueC.VALUE_INFINITE && alpha < beta && beta <= ValueC.VALUE_INFINITE);
            Debug.Assert((alpha == beta - 1) || PvNode);
            Debug.Assert(depth > DepthC.DEPTH_ZERO);

            MovesSearched ms = MovesSearchedBroker.GetObject();
            Move[] movesSearched = ms.movesSearched;

            StateInfo st = null;
            TTEntry tte = TT.StaticEntry;
            bool tteHasValue = false;
            UInt32 ttePos = 0;
            Key posKey = 0;
            Move ttMove, move, excludedMove, bestMove, threatMove;
            Depth ext, newDepth;
            Bound bt;
            Value bestValue, value, oldAlpha, ttValue;
            Value refinedValue, nullValue, futilityBase, futilityValue;
            bool isPvMove, inCheck, singularExtensionNode, givesCheck;
            bool captureOrPromotion, dangerous, doFullDepthSearch;
            int moveCount = 0, playedMoveCount = 0;
            Thread thisThread = pos.this_thread();
            SplitPoint sp = null;

            refinedValue = bestValue = value = -ValueC.VALUE_INFINITE;
            oldAlpha = alpha;
            inCheck = pos.in_check();
            ss[ssPos].ply = ss[ssPos - 1].ply + 1;

            // Used to send selDepth info to GUI
            if (PvNode && thisThread.maxPly < ss[ssPos].ply)
                thisThread.maxPly = ss[ssPos].ply;

            // Step 1. Initialize node
            if (SpNode)
            {
                ttMove = excludedMove = MoveC.MOVE_NONE;
                ttValue = ValueC.VALUE_ZERO;

                sp = ss[ssPos].sp;
                bestMove = sp.bestMove;
                threatMove = sp.threatMove;
                bestValue = sp.bestValue;
                moveCount = sp.moveCount; // Lock must be held here

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

                goto split_point_start;
            }
            else
            {
                ss[ssPos].currentMove = threatMove = ss[ssPos + 1].excludedMove = bestMove = MoveC.MOVE_NONE;
                ss[ssPos + 1].skipNullMove = 0; ss[ssPos + 1].reduction = DepthC.DEPTH_ZERO;
                ss[ssPos + 2].killers0 = ss[ssPos + 2].killers1 = MoveC.MOVE_NONE;
            }

            // Step 2. Check for aborted search and immediate draw
            // Enforce node limit here. FIXME: This only works with 1 search thread.
            if ((Limits.nodes != 0) && pos.nodes >= Limits.nodes)
                SignalsStop = true;

            if ((SignalsStop
                 || pos.is_draw(false)
                 || ss[ssPos].ply > Constants.MAX_PLY) && !RootNode)
            {
                MovesSearchedBroker.Free();
                return ValueC.VALUE_DRAW;
            }

            // Step 3. Mate distance pruning. Even if we mate at the next move our score
            // would be at best mate_in(ss[ssPos].ply+1), but if alpha is already bigger because
            // a shorter mate was found upward in the tree then there is no need to search
            // further, we will never beat current alpha. Same logic but with reversed signs
            // applies also in the opposite condition of being mated instead of giving mate,
            // in this case return a fail-high score.
            if (!RootNode)
            {
                alpha = Math.Max(Utils.mated_in(ss[ssPos].ply), alpha);
                beta = Math.Min(Utils.mate_in(ss[ssPos].ply + 1), beta);
                if (alpha >= beta)
                {
                    MovesSearchedBroker.Free();
                    return alpha;
                }
            }

            // Step 4. Transposition table lookup
            // We don't want the score of a partial search to overwrite a previous full search
            // TT value, so we use a different position key in case of an excluded move.
//.........这里部分代码省略.........
开发者ID:stevemulligan,项目名称:Portfish,代码行数:101,代码来源:Search.cs

示例3: do_evaluate

        /// evaluate() is the main evaluation function. It always computes two
        /// values, an endgame score and a middle game score, and interpolates
        /// between them based on the remaining material.
        internal static int do_evaluate(bool Trace, Position pos, ref int margin)
        {
            Debug.Assert(!pos.in_check());

            var ei = EvalInfoBroker.GetObject();

            Value marginsWHITE, marginsBLACK;
            int score = 0, mobilityWhite = 0, mobilityBlack = 0;

            // margins[] store the uncertainty estimation of position's evaluation
            // that typically is used by the search for pruning decisions.
            marginsWHITE = marginsBLACK = ValueC.VALUE_ZERO;

            // Initialize score by reading the incrementally updated scores included
            // in the position object (material + piece square tables) and adding
            // Tempo bonus. Score is computed from the point of view of white.
            score = pos.st.psqScore + (pos.sideToMove == ColorC.WHITE ? Tempo : -Tempo);

            // Probe the material hash table
            pos.this_thread().materialTable.probe(pos, out ei.mi);
            score += ((ei.mi.value << 16) + ei.mi.value);

            // If we have a specialized evaluation function for the current material
            // configuration, call it and return.
            if (ei.mi.evaluationFunction != null)
            {
                margin = ValueC.VALUE_ZERO;
                var retval = ei.mi.evaluationFunction(ei.mi.evaluationFunctionColor, pos);
                ei.pi = null;
                ei.mi = null;
                EvalInfoBroker.Free();
                return retval;
            }

            // Probe the pawn hash table
            pos.this_thread().pawnTable.probe(pos, out ei.pi);
            score += ei.pi.value;

            // Initialize attack and king safety bitboards
            init_eval_info(ColorC.WHITE, pos, ei);
            init_eval_info(ColorC.BLACK, pos, ei);

            // Evaluate pieces and mobility
            score += evaluate_pieces_of_color(ColorC.WHITE, Trace, pos, ei, ref mobilityWhite)
                     - evaluate_pieces_of_color(ColorC.BLACK, Trace, pos, ei, ref mobilityBlack);

            score += (((((((mobilityWhite - mobilityBlack) + 32768) & ~0xffff) / 0x10000
                         * (((Weights[EvalWeightC.Mobility] + 32768) & ~0xffff) / 0x10000)) / 0x100) << 16)
                      + (((short)((mobilityWhite - mobilityBlack) & 0xffff)
                          * ((short)(Weights[EvalWeightC.Mobility] & 0xffff))) / 0x100));

            // Evaluate kings after all other pieces because we need complete attack
            // information when computing the king safety evaluation.
            score += evaluate_king(ColorC.WHITE, Trace, pos, ei, ref marginsWHITE, ref marginsBLACK)
                     - evaluate_king(ColorC.BLACK, Trace, pos, ei, ref marginsWHITE, ref marginsBLACK);

            // Evaluate tactical threats, we need full attack information including king
            score += evaluate_threats(ColorC.WHITE, pos, ei) - evaluate_threats(ColorC.BLACK, pos, ei);

            // Evaluate passed pawns, we need full attack information including king
            score += evaluate_passed_pawns(ColorC.WHITE, pos, ei) - evaluate_passed_pawns(ColorC.BLACK, pos, ei);

            // If one side has only a king, check whether exists any unstoppable passed pawn
            if ((pos.st.npMaterialWHITE == 0) || (pos.st.npMaterialBLACK == 0))
            {
                score += evaluate_unstoppable_pawns(pos, ei);
            }

            // Evaluate space for both sides, only in middle-game.
            if (ei.mi.spaceWeight != 0)
            {
                var s = evaluate_space(ColorC.WHITE, pos, ei) - evaluate_space(ColorC.BLACK, pos, ei);
                score += ((((((((s * ei.mi.spaceWeight) << 16) + 32768) & ~0xffff) / 0x10000
                             * (((Weights[EvalWeightC.Space] + 32768) & ~0xffff) / 0x10000)) / 0x100) << 16)
                          + (((short)(((s * ei.mi.spaceWeight) << 16) & 0xffff)
                              * ((short)(Weights[EvalWeightC.Space] & 0xffff))) / 0x100));
            }

            // Scale winning side if position is more drawish that what it appears
            var sf = ((short)(score & 0xffff)) > ValueC.VALUE_DRAW
                         ? ei.mi.scale_factor_WHITE(pos)
                         : ei.mi.scale_factor_BLACK(pos);

            // If we don't already have an unusual scale factor, check for opposite
            // colored bishop endgames, and use a lower scale for those.
            if (ei.mi.gamePhase < PhaseC.PHASE_MIDGAME
                && (pos.pieceCount[ColorC.WHITE][PieceTypeC.BISHOP] == 1
                    && pos.pieceCount[ColorC.BLACK][PieceTypeC.BISHOP] == 1
                    && (((((pos.pieceList[ColorC.WHITE][PieceTypeC.BISHOP][0]
                            ^ pos.pieceList[ColorC.BLACK][PieceTypeC.BISHOP][0]) >> 3)
                          ^ (pos.pieceList[ColorC.WHITE][PieceTypeC.BISHOP][0]
                             ^ pos.pieceList[ColorC.BLACK][PieceTypeC.BISHOP][0])) & 1) != 0))
                && sf == ScaleFactorC.SCALE_FACTOR_NORMAL)
            {
                // Only the two bishops ?
                if (pos.st.npMaterialWHITE == Constants.BishopValueMidgame
                    && pos.st.npMaterialBLACK == Constants.BishopValueMidgame)
//.........这里部分代码省略.........
开发者ID:torfranz,项目名称:Portfish,代码行数:101,代码来源:Evaluate.cs

示例4: split

        // split() does the actual work of distributing the work at a node between
        // several available threads. If it does not succeed in splitting the node
        // (because no idle threads are available), the function immediately returns.
        // If splitting is possible, a SplitPoint object is initialized with all the
        // data that must be copied to the helper threads and then helper threads are
        // told that they have been assigned work. This will cause them to instantly
        // leave their idle loops and call search(). When all threads have returned from
        // search() then split() returns.
        internal static void split(
            bool Fake,
            Position pos,
            Stack[] ss,
            int ssPos,
            int alpha,
            int beta,
            ref int bestValue,
            ref int bestMove,
            int depth,
            int threatMove,
            int moveCount,
            MovePicker movePicker,
            int nodeType)
        {
            Debug.Assert(bestValue <= alpha && alpha < beta && beta <= ValueC.VALUE_INFINITE);
            Debug.Assert(pos.pos_is_ok());
            Debug.Assert(bestValue > -ValueC.VALUE_INFINITE);
            Debug.Assert(depth > DepthC.DEPTH_ZERO);

            var thisThread = pos.this_thread();

            Debug.Assert(thisThread.searching);
            Debug.Assert(thisThread.splitPointsSize < Constants.MAX_SPLITPOINTS_PER_THREAD);

            // Pick the next available split point from the split point stack
            var sp = thisThread.splitPoints[thisThread.splitPointsSize];

            sp.parentSplitPoint = thisThread.activeSplitPoint;
            sp.master = thisThread;
            sp.cutoff = false;
            sp.slavesMask = 1UL << thisThread.idx;
#if ACTIVE_REPARENT
            sp.allSlavesRunning = true;
#endif

            sp.depth = depth;
            sp.bestMove = bestMove;
            sp.threatMove = threatMove;
            sp.alpha = alpha;
            sp.beta = beta;
            sp.nodeType = nodeType;
            sp.bestValue = bestValue;
            sp.movePicker = movePicker;
            sp.moveCount = moveCount;
            sp.pos = pos;
            sp.nodes = 0;
            sp.ss = ss;
            sp.ssPos = ssPos;

            // Try to allocate available threads and ask them to start searching setting
            // 'searching' flag. This must be done under lock protection to avoid concurrent
            // allocation of the same slave by another master.
            ThreadHelper.lock_grab(splitLock);
            ThreadHelper.lock_grab(sp.Lock);

            thisThread.splitPointsSize++;
            thisThread.activeSplitPoint = sp;
            thisThread.activePosition = null;

            var slavesCnt = 1; // Master is always included
            Thread slave;
            while ((slave = Threads.available_slave(thisThread)) != null
                && ++slavesCnt <= Threads.maxThreadsPerSplitPoint && !Fake)
            {
                sp.slavesMask |= 1UL << slave.idx;
                slave.activeSplitPoint = sp;
                slave.searching = true; // Slave leaves idle_loop()

                slave.notify_one(); // Could be sleeping
            }

            ThreadHelper.lock_release(sp.Lock);
            ThreadHelper.lock_release(splitLock);

            // Everything is set up. The master thread enters the idle loop, from which
            // it will instantly launch a search, because its searching flag is set.
            // We pass the split point as a parameter to the idle loop, which means that
            // the thread will return from the idle loop when all slaves have finished
            // their work at this split point.
            if (slavesCnt > 1 || Fake)
            {
                thisThread.base_idle_loop(null); // Force a call to base class idle_loop()

                // In helpful master concept a master can help only a sub-tree of its split
                // point, and because here is all finished is not possible master is booked.
                Debug.Assert(!thisThread.searching);
                Debug.Assert(thisThread.activePosition == null);
            }

            // We have returned from the idle loop, which means that all threads are
            // finished. Note that setting searching and decreasing activeSplitPoints is
//.........这里部分代码省略.........
开发者ID:torfranz,项目名称:Portfish,代码行数:101,代码来源:Thread.cs

示例5: search

        // search<>() is the main search function for both PV and non-PV nodes and for
        // normal and SplitPoint nodes. When called just after a split point the search
        // is simpler because we have already probed the hash table, done a null move
        // search, and searched the first move before splitting, we don't have to repeat
        // all this work again. We also don't need to store anything to the hash table
        // here: This is taken care of after we return from the split point.
        internal static int search(int NT, Position pos, Stack[] ss, int ssPos, int alpha, int beta, int depth)
        {
            var PvNode = (NT == NodeTypeC.PV || NT == NodeTypeC.Root || NT == NodeTypeC.SplitPointPV
                          || NT == NodeTypeC.SplitPointRoot);
            var SpNode = (NT == NodeTypeC.SplitPointPV || NT == NodeTypeC.SplitPointNonPV
                          || NT == NodeTypeC.SplitPointRoot);
            var RootNode = (NT == NodeTypeC.Root || NT == NodeTypeC.SplitPointRoot);

            Debug.Assert(alpha >= -ValueC.VALUE_INFINITE && alpha < beta && beta <= ValueC.VALUE_INFINITE);
            Debug.Assert((PvNode || alpha == beta - 1));
            Debug.Assert(depth > DepthC.DEPTH_ZERO);

            var ms = MovesSearchedBroker.GetObject();
            var movesSearched = ms.movesSearched;

            StateInfo st = null;
            var tte = TT.StaticEntry;
            var tteHasValue = false;
            uint ttePos = 0;
            ulong posKey = 0;
            int ttMove, move, excludedMove, bestMove, threatMove;
            int ext, newDepth;
            int bestValue, value, ttValue;
            int eval = 0, nullValue, futilityValue;
            bool inCheck, givesCheck, pvMove, singularExtensionNode;
            bool captureOrPromotion, dangerous, doFullDepthSearch;
            int moveCount = 0, playedMoveCount = 0;
            SplitPoint sp = null;

            // Step 1. Initialize node
            var thisThread = pos.this_thread();
            //var threatExtension = false;
            inCheck = pos.in_check();
            
            if (SpNode)
            {
                sp = ss[ssPos].sp;
                bestMove = sp.bestMove;
                threatMove = sp.threatMove;
                bestValue = sp.bestValue;
                ttMove = excludedMove = MoveC.MOVE_NONE;
                ttValue = ValueC.VALUE_NONE;

                Debug.Assert(sp.bestValue > -ValueC.VALUE_INFINITE && sp.moveCount > 0);

                goto split_point_start;
            }

            bestValue = -ValueC.VALUE_INFINITE;
            ss[ssPos].currentMove = threatMove = ss[ssPos + 1].excludedMove = bestMove = MoveC.MOVE_NONE;
            ss[ssPos].ply = ss[ssPos - 1].ply + 1;
            ss[ssPos + 1].skipNullMove = 0;
            ss[ssPos + 1].reduction = DepthC.DEPTH_ZERO;
            ss[ssPos + 2].killers0 = ss[ssPos + 2].killers1 = MoveC.MOVE_NONE;

            // Used to send selDepth info to GUI
            if (PvNode && thisThread.maxPly < ss[ssPos].ply)
            {
                thisThread.maxPly = ss[ssPos].ply;
            }
            
            if (!RootNode)
            {
                // Step 2. Check for aborted search and immediate draw
                if ((SignalsStop || pos.is_draw(false) || ss[ssPos].ply > Constants.MAX_PLY))
                {
                    MovesSearchedBroker.Free();
                    return DrawValue[pos.sideToMove];
                }

                // Step 3. Mate distance pruning. Even if we mate at the next move our score
                // would be at best mate_in(ss->ply+1), but if alpha is already bigger because
                // a shorter mate was found upward in the tree then there is no need to search
                // further, we will never beat current alpha. Same logic but with reversed signs
                // applies also in the opposite condition of being mated instead of giving mate,
                // in this case return a fail-high score.
                alpha = Math.Max(Utils.mated_in(ss[ssPos].ply), alpha);
                beta = Math.Min(Utils.mate_in(ss[ssPos].ply + 1), beta);
                if (alpha >= beta)
                {
                    MovesSearchedBroker.Free();
                    return alpha;
                }
            }

            // Step 4. Transposition table lookup
            // We don't want the score of a partial search to overwrite a previous full search
            // TT value, so we use a different position key in case of an excluded move.
            excludedMove = ss[ssPos].excludedMove;
            posKey = (excludedMove != 0) ? pos.exclusion_key() : pos.key();
            tteHasValue = TT.probe(posKey, ref ttePos, out tte);
            ttMove = RootNode ? RootMoves[PVIdx].pv[0] : tteHasValue ? tte.move() : MoveC.MOVE_NONE;
            ttValue = tteHasValue ? value_from_tt(tte.value(), ss[ssPos].ply) : ValueC.VALUE_NONE;

//.........这里部分代码省略.........
开发者ID:torfranz,项目名称:Portfish,代码行数:101,代码来源:Search.cs

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