本文整理汇总了C#中Portfish.Position.exclusion_key方法的典型用法代码示例。如果您正苦于以下问题:C# Position.exclusion_key方法的具体用法?C# Position.exclusion_key怎么用?C# Position.exclusion_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Portfish.Position
的用法示例。
在下文中一共展示了Position.exclusion_key方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: search
//.........这里部分代码省略.........
// 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.
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_ZERO;
// At PV nodes we check for exact scores, while at non-PV nodes we check for
// a fail high/low. Biggest advantage at probing at PV nodes is to have a
// smooth experience in analysis mode. We don't probe at Root nodes otherwise
// we should also update RootMoveList to avoid bogus output.
if (!RootNode && tteHasValue && (PvNode ? tte.depth() >= depth && tte.type() == Bound.BOUND_EXACT
: can_return_tt(tte, depth, ttValue, beta)))
{
TT.entries[ttePos].set_generation(TT.generation);
ss[ssPos].currentMove = ttMove; // Can be MOVE_NONE
if (ttValue >= beta
&& (ttMove != 0)
&& !pos.is_capture_or_promotion(ttMove)
&& ttMove != ss[ssPos].killers0)
{
ss[ssPos].killers1 = ss[ssPos].killers0;
ss[ssPos].killers0 = ttMove;
}
MovesSearchedBroker.Free();
return ttValue;
}
// Step 5. Evaluate the position statically and update parent's gain statistics
if (inCheck)
ss[ssPos].eval = ss[ssPos].evalMargin = ValueC.VALUE_NONE;
else if (tteHasValue)
{
示例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 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;
//.........这里部分代码省略.........